From 5beec4c3fb440b17566bfbd578545ce605099176 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Sun, 11 Aug 2024 08:09:29 -0700 Subject: [PATCH 01/59] Add v02 of turbine endcal ecal --- detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp index a8fcafdc5..f1a61f02b 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp @@ -1,14 +1,17 @@ #include "DD4hep/DetFactoryHelper.h" #include "DD4hep/Printout.h" + #include "TMatrixT.h" // todo: remove gaudi logging and properly capture output #define endmsg std::endl #define lLog std::cout namespace MSG { + const std::string ERROR = " Error: "; const std::string DEBUG = " Debug: "; const std::string INFO = " Info: "; + } namespace det { From 3d53b85d99f3191caecf37f7330660c056da4790 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Wed, 21 Aug 2024 05:57:20 -0700 Subject: [PATCH 02/59] Fix up some printouts --- .../calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp index 4a4c43822..f3bc66ab7 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp @@ -84,11 +84,13 @@ namespace det { float BladeAngle = genericBladeElem.attr(_Unicode(angle)); bool decreaseAnglePerWheel = genericBladeElem.attr(_Unicode(decreaseAnglePerWheel)); + 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(); 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)); @@ -96,6 +98,7 @@ namespace det { if (TMath::Abs(TMath::Tan(BladeAngle)) < delZ/(2.*ri)) { 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; } @@ -194,6 +197,7 @@ namespace det { } else if (allNonActiveNotSensitive) { numNonActiveLayers = 1; } else { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v01", "Some non-active layers are sensitive and others are not -- this is likely a misconfiguration"); } @@ -210,6 +214,7 @@ namespace det { AbsThicko = AbsThicki; } 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 ); @@ -292,6 +297,7 @@ namespace det { } 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; @@ -312,6 +318,7 @@ namespace det { absBladeVol_pv.addPhysVolID("subtype", 0); // 0 = absorber, 1 = glue, 2 = cladding 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; @@ -391,6 +398,7 @@ namespace det { dd4hep::PlacedVolume LArVol_pv(activeVol.placeVolume(LArTotalLayerVol, posLayer)); dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "LAr layer: %d", iLayer ); + LArVol_pv.addPhysVolID("layer", iWheel*ECalEndcapNumCalibLayers+iLayer); riLayer = roLayer; @@ -405,6 +413,7 @@ namespace det { float delPhi = 2*TMath::Pi()/nUnitCells; 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()); @@ -511,6 +520,7 @@ namespace det { dd4hep::Tube bathAndServicesOuterShape(cryoDim.rmin2(), cryoDim.rmax1(), caloDim.dz()); // make it 4 volumes + 5th for detector envelope 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()); @@ -546,6 +556,7 @@ namespace det { cryoSidePhysVol.addPhysVolID("cryo", 1); cryoSidePhysVol.addPhysVolID("type", sidetype+3); dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Cryostat front volume set as sensitive"); + } dd4hep::DetElement cryoFrontDetElem(caloDetElem, "cryo_front", 0); cryoFrontDetElem.setPlacement(cryoFrontPhysVol); @@ -559,6 +570,7 @@ namespace det { std::string nobleLiquidMaterial = nobleLiquid.materialStr(); dd4hep::Volume bathVol(nobleLiquidMaterial + "_bath", bathOuterShape, aLcdd.material(nobleLiquidMaterial)); 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 @@ -568,6 +580,7 @@ namespace det { dd4hep::xml::DetElement supportTubeElem = calo.child(_Unicode(supportTube)); unsigned nWheels = supportTubeElem.attr(_Unicode(nWheels)); 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); @@ -633,6 +646,7 @@ createECalEndcapTurbine(dd4hep::Detector& aLcdd, dd4hep::xml::Handle_t aXmlEleme // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); 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); From 7799539bb190fd01256abf6d7e8635e3812e06e2 Mon Sep 17 00:00:00 2001 From: varnes Date: Wed, 21 Aug 2024 06:15:17 -0700 Subject: [PATCH 03/59] Fix printouts --- detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp index f3bc66ab7..fe11c3e2b 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp @@ -570,7 +570,7 @@ namespace det { std::string nobleLiquidMaterial = nobleLiquid.materialStr(); dd4hep::Volume bathVol(nobleLiquidMaterial + "_bath", bathOuterShape, aLcdd.material(nobleLiquidMaterial)); 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 From 19dcfda3f9a85df64bb44cd708f7effbf7025e4d Mon Sep 17 00:00:00 2001 From: varnes Date: Wed, 21 Aug 2024 06:19:22 -0700 Subject: [PATCH 04/59] Fix printouts --- detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp index fe11c3e2b..c16540f9f 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp @@ -84,8 +84,8 @@ namespace det { float BladeAngle = genericBladeElem.attr(_Unicode(angle)); bool decreaseAnglePerWheel = genericBladeElem.attr(_Unicode(decreaseAnglePerWheel)); - 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(); @@ -197,7 +197,6 @@ namespace det { } else if (allNonActiveNotSensitive) { numNonActiveLayers = 1; } else { - dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v01", "Some non-active layers are sensitive and others are not -- this is likely a misconfiguration"); } @@ -318,7 +317,6 @@ namespace det { absBladeVol_pv.addPhysVolID("subtype", 0); // 0 = absorber, 1 = glue, 2 = cladding 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; @@ -398,7 +396,6 @@ namespace det { dd4hep::PlacedVolume LArVol_pv(activeVol.placeVolume(LArTotalLayerVol, posLayer)); dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "LAr layer: %d", iLayer ); - LArVol_pv.addPhysVolID("layer", iWheel*ECalEndcapNumCalibLayers+iLayer); riLayer = roLayer; @@ -413,7 +410,6 @@ namespace det { float delPhi = 2*TMath::Pi()/nUnitCells; 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()); @@ -556,7 +552,6 @@ namespace det { cryoSidePhysVol.addPhysVolID("cryo", 1); cryoSidePhysVol.addPhysVolID("type", sidetype+3); dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Cryostat front volume set as sensitive"); - } dd4hep::DetElement cryoFrontDetElem(caloDetElem, "cryo_front", 0); cryoFrontDetElem.setPlacement(cryoFrontPhysVol); @@ -646,7 +641,7 @@ createECalEndcapTurbine(dd4hep::Detector& aLcdd, dd4hep::xml::Handle_t aXmlEleme // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); 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); From 00398c784961b81721d940957e781d932f2bbf57 Mon Sep 17 00:00:00 2001 From: varnes Date: Wed, 21 Aug 2024 08:09:12 -0700 Subject: [PATCH 05/59] Fix printouts --- detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp | 2 +- detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp index c16540f9f..991f93c71 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp @@ -641,7 +641,7 @@ createECalEndcapTurbine(dd4hep::Detector& aLcdd, dd4hep::xml::Handle_t aXmlEleme // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); 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); diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp index f1a61f02b..3173de9d1 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp @@ -181,13 +181,12 @@ namespace det { std::vector LArTotalLayerVols; std::vector electrodeBladeLayerVols; - dd4hep::Solid passiveShape = buildOneBlade(AbsThicki+GlueThick+CladdingThick, AbsThicko+GlueThick+CladdingThick, xRange, ro, ri, BladeAngle, delZ ); dd4hep::Volume passiveVol("passive", passiveShape, aLcdd.material("Air")); dd4hep::Solid activeShape = buildOneBlade(ElectrodeThick+LArgapi*2, ElectrodeThick+LArgapo*2, xRange, ro, ri, BladeAngle, delZ); dd4hep::Volume activeVol("active", activeShape, aLcdd.material("Air")); - + unsigned numNonActiveLayers = 1; // check that either all non-active volumes are set to sensitive (for // sampling fraction calculations) or none are (for normal running) From 59303dcc722a262b44d6c239ee584989fd24703d Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Wed, 21 Aug 2024 14:14:30 -0700 Subject: [PATCH 06/59] Fix printouts --- detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp index 3173de9d1..1ffd0d329 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp @@ -87,6 +87,7 @@ namespace det { dd4hep::xml::DetElement nobleLiquidElem = genericBladeElem.child(_Unicode(nobleLiquidGap)); float BladeAngle = 0.0, AbsThickMin = 0.0, BladeThicknessScaleFactor=0.0; + // hardcode for three wheels if (iWheel == 0) { BladeAngle = genericBladeElem.attr(_Unicode(angle1)); @@ -107,6 +108,7 @@ namespace det { dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "Making wheel with inner, outer radii %f, %f", ri, ro); dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "Blade angle is %f ", BladeAngle); dd4hep::xml::Dimension dim(aXmlElement.child(_Unicode(dimensions))); + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "delZ is %f", delZ); if (TMath::Abs(TMath::Tan(BladeAngle)) < delZ/(2.*ri)) { @@ -131,7 +133,9 @@ namespace det { bool sameNUnitCells = genericBladeElem.attr(_Unicode(sameNUnitCells)); char* nUnitCellsStrArr = (char*)genericBladeElem.attr(_Unicode(nUnitCells)).c_str(); char* nUnitCellsCStr = strtok(nUnitCellsStrArr, " "); + int nUnitCells = -1; + if (!sameNUnitCells) { for (unsigned i = 0; i < iWheel; i++) { nUnitCellsCStr = strtok(NULL, " "); @@ -186,7 +190,7 @@ namespace det { dd4hep::Solid activeShape = buildOneBlade(ElectrodeThick+LArgapi*2, ElectrodeThick+LArgapo*2, xRange, ro, ri, BladeAngle, delZ); dd4hep::Volume activeVol("active", activeShape, aLcdd.material("Air")); - + unsigned numNonActiveLayers = 1; // check that either all non-active volumes are set to sensitive (for // sampling fraction calculations) or none are (for normal running) From 62d158f606e10d25f9c2fd75e805c2815fa22917 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Wed, 21 Aug 2024 17:15:38 -0700 Subject: [PATCH 07/59] Fix printout --- detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp index 991f93c71..0c14f811c 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp @@ -296,7 +296,6 @@ namespace det { } 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; @@ -565,7 +564,7 @@ namespace det { std::string nobleLiquidMaterial = nobleLiquid.materialStr(); dd4hep::Volume bathVol(nobleLiquidMaterial + "_bath", bathOuterShape, aLcdd.material(nobleLiquidMaterial)); 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 From fea6ea0162fb605e71c740f8f09f2136bafd7cd5 Mon Sep 17 00:00:00 2001 From: Alvaro Tolosa Delgado Date: Tue, 6 Aug 2024 16:53:36 +0200 Subject: [PATCH 08/59] IDEA with DRC dedicated test added --- test/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 79ded71e7..bcbe6d79c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -128,6 +128,16 @@ endif() # SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 600) #endif() +#-------------------------------------------------- +# test for IDEA o1 v03, with DRC +if(DCH_INFO_H_EXIST) +SET( test_name "test_IDEA_with_DRC_o1_v03" ) +ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" + ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py --gun.direction "3 4 0") + SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 1200) +endif() + + #-------------------------------------------------- # test for ALLEGRO o1 v02 SET( test_name "test_ALLEGRO_o1_v02" ) From 98bef5c5f3c48244ddb347cdfada764c06f9a757 Mon Sep 17 00:00:00 2001 From: Alvaro Tolosa Delgado Date: Tue, 6 Aug 2024 18:03:44 +0200 Subject: [PATCH 09/59] fix IDEA with DRC test --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bcbe6d79c..3c9e3c817 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,7 +133,7 @@ endif() if(DCH_INFO_H_EXIST) SET( test_name "test_IDEA_with_DRC_o1_v03" ) ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" - ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py --gun.direction "3 4 0") + "ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py --gun.direction '(3,4,0)'") SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 1200) endif() From 002c8f4f510d5087fab8af55a9e41c10920fc172 Mon Sep 17 00:00:00 2001 From: Alvaro Tolosa Delgado Date: Tue, 6 Aug 2024 18:16:19 +0200 Subject: [PATCH 10/59] apply other SD action to DRC --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3c9e3c817..9e8e9799c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,7 +133,7 @@ endif() if(DCH_INFO_H_EXIST) SET( test_name "test_IDEA_with_DRC_o1_v03" ) ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" - "ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py --gun.direction '(3,4,0)'") + "ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py --gun.direction '(3,4,0)' --action.mapActions 'DRcalo, Geant4SimpleTrackerAction' ) SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 1200) endif() From 381ce733526cac0e03ef5963797c6cf19b3e377b Mon Sep 17 00:00:00 2001 From: Alvaro Tolosa Delgado Date: Wed, 7 Aug 2024 09:24:15 +0200 Subject: [PATCH 11/59] still not working... --- test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9e8e9799c..a81149bc9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,7 +133,8 @@ endif() if(DCH_INFO_H_EXIST) SET( test_name "test_IDEA_with_DRC_o1_v03" ) ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" - "ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py --gun.direction '(3,4,0)' --action.mapActions 'DRcalo, Geant4SimpleTrackerAction' ) + "ddsim --compactFile=/home/alvarotd/work/update_main_detectors_after_DRC/k4geo/test/compact/IDEA_withDRC_o1_v03.xml --steeringFile=/home/alvarotd/work/update_main_detectors_after_DRC/k4geo/test/../example/SteeringFile_IDEA_o1_v03.py --gun.direction '(3,4,0)' + " ) SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 1200) endif() From 80b938a8c0f36f1863236c85cdce456cfa6dcb77 Mon Sep 17 00:00:00 2001 From: Alvaro Tolosa Delgado Date: Wed, 7 Aug 2024 09:46:03 +0200 Subject: [PATCH 12/59] replace absolute path by cmake variables in ctest --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a81149bc9..1a58e952b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,7 +133,7 @@ endif() if(DCH_INFO_H_EXIST) SET( test_name "test_IDEA_with_DRC_o1_v03" ) ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" - "ddsim --compactFile=/home/alvarotd/work/update_main_detectors_after_DRC/k4geo/test/compact/IDEA_withDRC_o1_v03.xml --steeringFile=/home/alvarotd/work/update_main_detectors_after_DRC/k4geo/test/../example/SteeringFile_IDEA_o1_v03.py --gun.direction '(3,4,0)' + "ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py --gun.direction '(3,4,0)' " ) SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 1200) endif() From 7d831179ace8f492fc17bb9fbc7a97473a3b8ec8 Mon Sep 17 00:00:00 2001 From: Alvaro Tolosa Delgado Date: Wed, 7 Aug 2024 18:26:16 +0200 Subject: [PATCH 13/59] IDEA+DRC test is now working --- test/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1a58e952b..29c9ebd4b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,9 +133,8 @@ endif() if(DCH_INFO_H_EXIST) SET( test_name "test_IDEA_with_DRC_o1_v03" ) ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" - "ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py --gun.direction '(3,4,0)' - " ) - SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 1200) + ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py -G --gun.distribution uniform --random.seed 1988301045 ) + SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 600) endif() From b4e2fab77cecab259d7a891bf9857e0717fd9bd9 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Mon, 5 Aug 2024 08:58:08 +0200 Subject: [PATCH 14/59] copy TrackerBarrel_o1_v06 --- detector/tracker/TrackerBarrel_o1_v06_geo.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp index 9ba5c30f0..cf6c4c881 100644 --- a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp +++ b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp @@ -122,6 +122,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s // Assembly assembly (det_name); std::map volumes; std::map sensitives; + PlacedVolume pv; @@ -152,7 +153,6 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s xml_comp_t x_mod = mi; xml_comp_t m_env = x_mod.child(_U(module_envelope)); std::string m_nam = x_mod.nameStr(); - if ( volumes.find(m_nam) != volumes.end() ) { printout(ERROR,"TrackerBarrel","Logics error in building modules."); @@ -213,6 +213,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s // int type = x_layer.type(); std::string m_nam = x_layer.moduleStr(); std::string lay_nam = _toString(x_layer.id(),"layer%d"); + Assembly lay_vol (lay_nam); // Create the layer envelope volume. double phi0 = x_layout.phi0(); // Starting phi of first sensor. double phi_tilt = x_layout.phi_tilt(); // Phi tilt of a sensor. @@ -302,12 +303,14 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s /////////////////// } + } // Create the PhysicalVolume for the layer. pv = envelope.placeVolume(lay_vol); // Place layer in mother pv.addPhysVolID("layer", lay_id); // Set the layer ID. lay_elt.setAttributes(theDetector,lay_vol,x_layer.regionStr(),x_layer.limitsStr(),x_layer.visStr()); lay_elt.setPlacement(pv); + } sdet.setAttributes(theDetector,envelope,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); sdet.addExtension< ZPlanarData >( zPlanarData ) ; From a988a5e172e351c7d18001e03b5234b03494fa20 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Thu, 8 Aug 2024 16:10:22 +0200 Subject: [PATCH 15/59] copy CLD_o2_v06 to CLD_o2_v07 --- FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml | 439 +++++++++++++ .../CLD_o2_v07/InnerTracker_o2_v07.xml | 582 ++++++++++++++++++ .../compact/CLD_o2_v07/LumiCal_o3_v02_04.xml | 188 ++++++ .../CLD_o2_v07/OuterTracker_o2_v07.xml | 226 +++++++ 4 files changed, 1435 insertions(+) create mode 100644 FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml create mode 100644 FCCee/CLD/compact/CLD_o2_v07/InnerTracker_o2_v07.xml create mode 100644 FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_04.xml create mode 100644 FCCee/CLD/compact/CLD_o2_v07/OuterTracker_o2_v07.xml diff --git a/FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml b/FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml new file mode 100644 index 000000000..853cd02d4 --- /dev/null +++ b/FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml @@ -0,0 +1,439 @@ + + + + The compact format for the FCCee Detector design + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + suggested naming convention: + + main parameters: + + DET_inner_radius : inner radius of tube like envelope ( inscribed cylinder ) + DET_outer_radius : outer radius of tube like envelope ( circumscribed cylinder ) + DET_half_length : half length along z axis + DET_min_z : smallest absolute value on z-axis + DET_max_z : largest absolute value on z-axis + DET_inner_symmetry : number of sides on the inside ( 0 for tube ) + DET_outer_symmetry : number of sides on the inside ( 0 for tube ) + DET_inner_phi0 : optional rotation of the inner polygon ( in r-phi plane ) + DET_outer_phi0 : optional rotation of the outer polygon ( in r-phi plane ) + + additional parameters for cutting away volumes/shapes use one of the above with a number + appended and/or an extra specifiaction such as cone ( for a cut away cone ) + + DET_inner_radius_1 + DET_outer_radius_2 + DET_cone_min_z + DET_cone_max_z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FCCee/CLD/compact/CLD_o2_v07/InnerTracker_o2_v07.xml b/FCCee/CLD/compact/CLD_o2_v07/InnerTracker_o2_v07.xml new file mode 100644 index 000000000..8406b1115 --- /dev/null +++ b/FCCee/CLD/compact/CLD_o2_v07/InnerTracker_o2_v07.xml @@ -0,0 +1,582 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tracking detectors + + + + + + + + + + + + + Inner Tracker Assembly + + + + + + + + + + + + + + + + + + + + + + + + + ${GlobalTrackerReadoutID} + + + ${GlobalTrackerReadoutID} + + + + + + + + + + Silicon Inner Tracker Barrel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Silicon Inner Tracker Endcaps + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3.5959*cm = X0 for Carbon fibre + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + The next section is the cable for the vertex + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_04.xml b/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_04.xml new file mode 100644 index 000000000..cbc708e20 --- /dev/null +++ b/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_04.xml @@ -0,0 +1,188 @@ + + + + + + + + + + system:8,barrel:3,layer:8,slice:8,r:32:-16,phi:-16 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FCCee/CLD/compact/CLD_o2_v07/OuterTracker_o2_v07.xml b/FCCee/CLD/compact/CLD_o2_v07/OuterTracker_o2_v07.xml new file mode 100644 index 000000000..fb8e27d9b --- /dev/null +++ b/FCCee/CLD/compact/CLD_o2_v07/OuterTracker_o2_v07.xml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Tracking detectors + + + + + Outer Tracker Assembly + + + + + + + + + + + + + + + + + + + + ${GlobalTrackerReadoutID} + + + ${GlobalTrackerReadoutID} + + + + + + + + + + + Silicon Outer Tracker Barrel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Silicon Outer Tracker Endcaps + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 0dfacfa01472226d1a735db759902983e2554ca1 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Thu, 8 Aug 2024 16:22:21 +0200 Subject: [PATCH 16/59] update version --- FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml | 439 -------------------- 1 file changed, 439 deletions(-) delete mode 100644 FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml diff --git a/FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml b/FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml deleted file mode 100644 index 853cd02d4..000000000 --- a/FCCee/CLD/compact/CLD_o2_v07/CLD_o2_v06.xml +++ /dev/null @@ -1,439 +0,0 @@ - - - - The compact format for the FCCee Detector design - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - suggested naming convention: - - main parameters: - - DET_inner_radius : inner radius of tube like envelope ( inscribed cylinder ) - DET_outer_radius : outer radius of tube like envelope ( circumscribed cylinder ) - DET_half_length : half length along z axis - DET_min_z : smallest absolute value on z-axis - DET_max_z : largest absolute value on z-axis - DET_inner_symmetry : number of sides on the inside ( 0 for tube ) - DET_outer_symmetry : number of sides on the inside ( 0 for tube ) - DET_inner_phi0 : optional rotation of the inner polygon ( in r-phi plane ) - DET_outer_phi0 : optional rotation of the outer polygon ( in r-phi plane ) - - additional parameters for cutting away volumes/shapes use one of the above with a number - appended and/or an extra specifiaction such as cone ( for a cut away cone ) - - DET_inner_radius_1 - DET_outer_radius_2 - DET_cone_min_z - DET_cone_max_z - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From aa1f811ef181e6eb720ad23b4b51ea912292ef68 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Thu, 8 Aug 2024 16:22:50 +0200 Subject: [PATCH 17/59] Use new TrackerBarrel --- .../CLD_o2_v07/InnerTracker_o2_v07.xml | 582 ------------------ .../CLD_o2_v07/OuterTracker_o2_v07.xml | 226 ------- 2 files changed, 808 deletions(-) delete mode 100644 FCCee/CLD/compact/CLD_o2_v07/InnerTracker_o2_v07.xml delete mode 100644 FCCee/CLD/compact/CLD_o2_v07/OuterTracker_o2_v07.xml diff --git a/FCCee/CLD/compact/CLD_o2_v07/InnerTracker_o2_v07.xml b/FCCee/CLD/compact/CLD_o2_v07/InnerTracker_o2_v07.xml deleted file mode 100644 index 8406b1115..000000000 --- a/FCCee/CLD/compact/CLD_o2_v07/InnerTracker_o2_v07.xml +++ /dev/null @@ -1,582 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Tracking detectors - - - - - - - - - - - - - Inner Tracker Assembly - - - - - - - - - - - - - - - - - - - - - - - - - ${GlobalTrackerReadoutID} - - - ${GlobalTrackerReadoutID} - - - - - - - - - - Silicon Inner Tracker Barrel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Silicon Inner Tracker Endcaps - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3.5959*cm = X0 for Carbon fibre - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - The next section is the cable for the vertex - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FCCee/CLD/compact/CLD_o2_v07/OuterTracker_o2_v07.xml b/FCCee/CLD/compact/CLD_o2_v07/OuterTracker_o2_v07.xml deleted file mode 100644 index fb8e27d9b..000000000 --- a/FCCee/CLD/compact/CLD_o2_v07/OuterTracker_o2_v07.xml +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - Tracking detectors - - - - - Outer Tracker Assembly - - - - - - - - - - - - - - - - - - - - ${GlobalTrackerReadoutID} - - - ${GlobalTrackerReadoutID} - - - - - - - - - - - Silicon Outer Tracker Barrel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Silicon Outer Tracker Endcaps - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 8dec7d3dfcc0792a0be482bd152fe641466f7f3d Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Fri, 9 Aug 2024 13:29:43 +0200 Subject: [PATCH 18/59] TrackerBarrel_o1_v06 remove using namespace std --- detector/tracker/TrackerBarrel_o1_v06_geo.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp index cf6c4c881..9d9b212af 100644 --- a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp +++ b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp @@ -122,7 +122,6 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s // Assembly assembly (det_name); std::map volumes; std::map sensitives; - PlacedVolume pv; From 33e5dd82eefbd9428745ae2ee086fb3db20cbff2 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Fri, 9 Aug 2024 14:12:26 +0200 Subject: [PATCH 19/59] move NeighbourSurfacesData population into a function --- detector/tracker/TrackerBarrel_o1_v06_geo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp index 9d9b212af..8a0ed7c62 100644 --- a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp +++ b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp @@ -254,7 +254,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s staveElementTemplate.add(sensorElement); sensorElement.setPlacement(sensorPv); - // also add a DetElement for the sensitive component + for (const PlacedVolume& wafer_pv : waferVols) { DetElement comp_elt(sensorElement, wafer_pv.volume().name(), i); comp_elt.setPlacement(wafer_pv); From eb3e5756e36402c551a63bed478bb7b4623bfe17 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Fri, 9 Aug 2024 15:02:16 +0200 Subject: [PATCH 20/59] Move LayerLayout population out of the sensor loop --- detector/tracker/TrackerBarrel_o1_v06_geo.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp index 8a0ed7c62..f482b219f 100644 --- a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp +++ b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp @@ -309,7 +309,6 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s pv.addPhysVolID("layer", lay_id); // Set the layer ID. lay_elt.setAttributes(theDetector,lay_vol,x_layer.regionStr(),x_layer.limitsStr(),x_layer.visStr()); lay_elt.setPlacement(pv); - } sdet.setAttributes(theDetector,envelope,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); sdet.addExtension< ZPlanarData >( zPlanarData ) ; From 0fe10d94cf4d5ce0e472345b131e85c2e2db8244 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Wed, 14 Aug 2024 09:34:25 +0200 Subject: [PATCH 21/59] TrackerBarrel_o1_v06 add assembly stave --- detector/tracker/TrackerBarrel_o1_v06_geo.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp index f482b219f..4d684d7cf 100644 --- a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp +++ b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp @@ -254,7 +254,6 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s staveElementTemplate.add(sensorElement); sensorElement.setPlacement(sensorPv); - for (const PlacedVolume& wafer_pv : waferVols) { DetElement comp_elt(sensorElement, wafer_pv.volume().name(), i); comp_elt.setPlacement(wafer_pv); From 69fccc957495c7d624b176485de876e3082bacc4 Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Thu, 4 Jul 2024 19:40:29 +0200 Subject: [PATCH 22/59] addExtensionsToHCalAllegro --- .../HCalThreePartsEndcap_o1_v01_geo.cpp | 896 +++++++++--------- .../calorimeter/HCalTileBarrel_o1_v01_geo.cpp | 92 +- 2 files changed, 518 insertions(+), 470 deletions(-) diff --git a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp index 34544c2e2..1baccf00c 100644 --- a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp @@ -1,467 +1,487 @@ // DD4hep #include "DD4hep/DetFactoryHelper.h" +#include // todo: remove gaudi logging and properly capture output #define endmsg std::endl #define lLog std::cout namespace MSG { -const std::string DEBUG = " Debug: "; -const std::string INFO = " Info: "; +const std::string ERROR = "createHCalThrePartsEndcap ERROR "; +const std::string DEBUG = "createHCalThrePartsEndcap DEBUG "; +const std::string INFO = "createHCalThrePartsEndcap INFO "; } using dd4hep::Volume; using dd4hep::DetElement; using dd4hep::xml::Dimension; using dd4hep::PlacedVolume; +using xml_comp_t = dd4hep::xml::Component; +using xml_det_t = dd4hep::xml::DetElement; +using xml_h = dd4hep::xml::Handle_t; namespace det { -void buildEC(dd4hep::Detector& aLcdd, dd4hep::SensitiveDetector& aSensDet, dd4hep::Volume& aEnvelope, - dd4hep::DetElement& aHCal, xml_det_t aXmlElement, int sign) { - - dd4hep::SensitiveDetector sensDet = aSensDet; - Dimension sensDetType = aXmlElement.child(_Unicode(sensitive)); - sensDet.setType(sensDetType.typeStr()); - - Dimension dimensions(aXmlElement.child(_Unicode(dimensions))); - xml_comp_t xEndPlate = aXmlElement.child(_Unicode(end_plate)); - double dZEndPlate = xEndPlate.thickness() / 2.; - xml_comp_t xFacePlate = aXmlElement.child(_Unicode(face_plate)); - double dRhoFacePlate = xFacePlate.thickness() / 2.; - xml_comp_t xSpace = aXmlElement.child(_Unicode(plate_space)); // to avoid overlaps - double space = xSpace.thickness(); - xml_comp_t xSteelSupport = aXmlElement.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; - - double sensitiveBarrel1Rmin = dimensions.rmin1() + 2 * dRhoFacePlate + space; - double sensitiveBarrel2Rmin = dimensions.rmin2() + 2 * dRhoFacePlate + space; - double sensitiveBarrel3Rmin = dimensions.rmin() + 2 * dRhoFacePlate + space; - - // Offset in z is given as distance from 0 to the middle of the Calorimeter volume - double extBarrelOffset1 = dimensions.offset(); - double extBarrelOffset2 = dimensions.z_offset(); - double extBarrelOffset3 = dimensions.v_offset(); - - // Hard-coded assumption that we have two different sequences for the modules - std::vector sequences = {aXmlElement.child(_Unicode(sequence_a)), aXmlElement.child(_Unicode(sequence_b))}; - // NOTE: This assumes that both have the same dimensions! - Dimension sequenceDimensions(sequences[1].dimensions()); - double dzSequence = sequenceDimensions.dz(); - lLog << MSG::DEBUG << "sequence thickness " << dzSequence << endmsg; - - // calculate the number of modules fitting in Z - unsigned int numSequencesZ1 = static_cast((2 * dimensions.width() - 2 * dZEndPlate - space) / dzSequence); - unsigned int numSequencesZ2 = static_cast((2 * dimensions.dz() - 2 * dZEndPlate - space) / dzSequence); - unsigned int numSequencesZ3 = static_cast((2 * dimensions.z_length() - 2 * dZEndPlate - space) / dzSequence); - - unsigned int numSequencesR1 = 0; - unsigned int numSequencesR2 = 0; - unsigned int numSequencesR3 = 0; - double moduleDepth1 = 0.; - double moduleDepth2 = 0.; - double moduleDepth3 = 0.; - std::vector layerDepths1 = std::vector(); - std::vector layerDepths2 = std::vector(); - std::vector layerDepths3 = std::vector(); - - // get all 'layer' children of the 'layers' tag - std::vector Layers; - for (xml_coll_t xCompColl(aXmlElement.child(_Unicode(layers)), _Unicode(layer)); xCompColl; - ++xCompColl) { - Layers.push_back(xCompColl); - } - - for (std::vector::iterator it = Layers.begin(); it != Layers.end(); ++it) { - xml_comp_t layer = *it; - Dimension layerDimension(layer.dimensions()); - numSequencesR1 += layerDimension.nmodules(); - numSequencesR2 += layerDimension.nModules(); - numSequencesR3 += layerDimension.nPads(); - for (int nLayer = 0; nLayer < layerDimension.nmodules(); nLayer++) { - moduleDepth1 += layerDimension.dr(); - layerDepths1.push_back(layerDimension.dr()); - } - for (int nLayer = 0; nLayer < layerDimension.nModules(); nLayer++) { - moduleDepth2 += layerDimension.dr(); - layerDepths2.push_back(layerDimension.dr()); - } - for (int nLayer = 0; nLayer < layerDimension.nPads(); nLayer++) { - moduleDepth3 += layerDimension.dr(); - layerDepths3.push_back(layerDimension.dr()); +static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4hep::SensitiveDetector sensDet){ + xml_det_t xmlDet = xmlElement; + std::string detName = xmlDet.nameStr(); + + // Make DetElement + dd4hep::DetElement caloDetElem(detName, xmlDet.id()); + + // Make volume that envelopes the whole barrel; set material to air + Dimension dimensions(xmlDet.dimensions()); + + dd4hep::Tube envelope(dimensions.rmin(), dimensions.rmax1(), (dimensions.v_offset() + dimensions.z_length())); + dd4hep::Tube negative1(dimensions.rmin(), dimensions.rmax1(), (dimensions.offset() - dimensions.width())); + dd4hep::Tube negative2(dimensions.rmin(), dimensions.rmin1(), (dimensions.z_offset() - dimensions.dz())); + dd4hep::Tube negative3(dimensions.rmin(), dimensions.rmin2(), (dimensions.v_offset() - dimensions.z_length())); + + dd4hep::SubtractionSolid envelopeShapeTmp1(envelope, negative1); + dd4hep::SubtractionSolid envelopeShapeTmp2(envelopeShapeTmp1, negative2); + dd4hep::SubtractionSolid envelopeShape(envelopeShapeTmp2, negative3); + + Volume envelopeVolume(detName + "_volume", envelopeShape, lcdd.air()); + envelopeVolume.setVisAttributes(lcdd, dimensions.visStr()); + + // Set sensitive detector type + Dimension sensDetType = xmlElement.child(_Unicode(sensitive)); + sensDet.setType(sensDetType.typeStr()); + + // Dimension dimensions(xmlElement.child(_Unicode(dimensions))); + xml_comp_t xEndPlate = xmlElement.child(_Unicode(end_plate)); + double dZEndPlate = xEndPlate.thickness() / 2.; + xml_comp_t xFacePlate = xmlElement.child(_Unicode(face_plate)); + double dRhoFacePlate = xFacePlate.thickness() / 2.; + xml_comp_t xSpace = xmlElement.child(_Unicode(plate_space)); // to avoid overlaps + 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; + + // Calculate sensitive barrel dimensions + double sensitiveBarrel1Rmin = dimensions.rmin1() + 2 * dRhoFacePlate + space; + double sensitiveBarrel2Rmin = dimensions.rmin2() + 2 * dRhoFacePlate + space; + double sensitiveBarrel3Rmin = dimensions.rmin() + 2 * dRhoFacePlate + space; + + // Offset in z is given as distance from 0 to the middle of the Calorimeter volume + double extBarrelOffset1 = dimensions.offset(); + double extBarrelOffset2 = dimensions.z_offset(); + double extBarrelOffset3 = dimensions.v_offset(); + + // Hard-coded assumption that we have two different sequences for the modules + std::vector sequences = {xmlElement.child(_Unicode(sequence_a)), xmlElement.child(_Unicode(sequence_b))}; + // NOTE: This assumes that both have the same dimensions! + Dimension sequenceDimensions(sequences[1].dimensions()); + double dzSequence = sequenceDimensions.dz(); + lLog << MSG::DEBUG << "sequence thickness " << dzSequence << endmsg; + + // calculate the number of modules fitting in Z + unsigned int numSequencesZ1 = static_cast((2 * dimensions.width() - 2 * dZEndPlate - space) / dzSequence); + unsigned int numSequencesZ2 = static_cast((2 * dimensions.dz() - 2 * dZEndPlate - space) / dzSequence); + unsigned int numSequencesZ3 = static_cast((2 * dimensions.z_length() - 2 * dZEndPlate - space) / dzSequence); + + unsigned int numSequencesR1 = 0; + unsigned int numSequencesR2 = 0; + unsigned int numSequencesR3 = 0; + double moduleDepth1 = 0.; + double moduleDepth2 = 0.; + double moduleDepth3 = 0.; + + // MM: using layers and Layers is not very fortunate + std::vector layerDepths1 = std::vector(); + std::vector layerDepths2 = std::vector(); + std::vector layerDepths3 = std::vector(); + + // get all 'layer' children of the 'layers' tag + std::vector Layers; + for (xml_coll_t xCompColl(xmlElement.child(_Unicode(layers)), _Unicode(layer)); xCompColl; ++xCompColl){ + Layers.push_back(xCompColl); } - } - - lLog << MSG::DEBUG << "retrieved number of layers in first Endcap part: " << numSequencesR1 - << " , which end up to a full module depth in rho of " << moduleDepth1 << endmsg; - lLog << MSG::DEBUG << "retrieved number of layers in first Endcap part: " << layerDepths1.size() << endmsg; - lLog << MSG::DEBUG << "retrieved number of layers in second Endcap part: " << numSequencesR2 - << " , which end up to a full module depth in rho of " << moduleDepth2 << endmsg; - lLog << MSG::DEBUG << "retrieved number of layers in second Endcap part: " << layerDepths2.size() << endmsg; - lLog << MSG::DEBUG << "retrieved number of layers in third Endcap part: " << numSequencesR3 - << " , which end up to a full module depth in rho of " << moduleDepth3 << endmsg; - lLog << MSG::DEBUG << "retrieved number of layers in third Endcap part: " << layerDepths3.size() << endmsg; - - lLog << MSG::INFO << "constructing first part EC: with offset " << extBarrelOffset1 << ": "<< numSequencesZ1 - << " rings in Z, " << numSequencesR1 << " layers in Rho, " << numSequencesR1 * numSequencesZ1 - << " tiles" << endmsg; - - lLog << MSG::INFO << "constructing second part EC: with offset " << extBarrelOffset2 << ": " << numSequencesZ2 - << " rings in Z, " << numSequencesR2 << " layers in Rho, " - << layerDepths2.size() * numSequencesZ2 << " tiles" << endmsg; - - lLog << MSG::INFO << "constructing third part EC: with offset " << extBarrelOffset3 << ": " << numSequencesZ3 - << " rings in Z, " << numSequencesR3 << " layers in Rho, " - << layerDepths3.size() * numSequencesZ3 << " tiles" << endmsg; - - lLog << MSG::INFO << "number of channels: " - << (numSequencesR1 * numSequencesZ1) + (numSequencesR2 * numSequencesZ2) + (numSequencesR3 * numSequencesZ3) - << endmsg; - - // Calculate correction along z based on the module size (can only have natural number of modules) - double dzDetector1 = (numSequencesZ1 * dzSequence) / 2 + 2 * dZEndPlate + space; - lLog << MSG::INFO - << "correction of dz (negative = size reduced) first part EC :" << dzDetector1*2 - dimensions.width()*2 - << endmsg; - double dzDetector2 = (numSequencesZ2 * dzSequence) / 2; - 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; - - double dzDetector3 = (numSequencesZ3 * dzSequence) / 2 + 2 * dZEndPlate + space; - lLog << MSG::INFO << "dz third part EC:" << dzDetector2 * 2 - << endmsg; - - // Add structural support made of steel inside of HCal - DetElement facePlate1(aHCal, "FacePlate_" + std::to_string(1 * sign), 0); - dd4hep::Tube facePlateShape1(dimensions.rmin1(), (sensitiveBarrel1Rmin - space), - (dzDetector1 - 2 * dZEndPlate - space)); - Volume facePlateVol1("facePlateVol1", facePlateShape1, aLcdd.material(xFacePlate.materialStr())); - facePlateVol1.setVisAttributes(aLcdd, xFacePlate.visStr()); - dd4hep::Position offsetFace1(0, 0, sign * extBarrelOffset1); - - // Faceplate for 2nd part of extended Barrel - DetElement facePlate2(aHCal, "FacePlate_" + std::to_string(2 * sign), 0); - dd4hep::Tube facePlateShape2(dimensions.rmin2(), (sensitiveBarrel2Rmin - space), - dzDetector2); - Volume facePlateVol2("facePlateVol2", facePlateShape2, aLcdd.material(xFacePlate.materialStr())); - facePlateVol2.setVisAttributes(aLcdd, xFacePlate.visStr()); - dd4hep::Position offsetFace2(0, 0, sign * extBarrelOffset2); - - // Faceplate for 3rd part of extended Barrel - DetElement facePlate3(aHCal, "FacePlate_" + std::to_string(3 * sign), 0); - dd4hep::Tube facePlateShape3(dimensions.rmin(), (sensitiveBarrel3Rmin - space), - (dzDetector3 - 2 * dZEndPlate - space)); - Volume facePlateVol3("facePlateVol3", facePlateShape3, aLcdd.material(xFacePlate.materialStr())); - facePlateVol3.setVisAttributes(aLcdd, xFacePlate.visStr()); - dd4hep::Position offsetFace3(0, 0, sign * extBarrelOffset3); - - PlacedVolume placedFacePlate1 = aEnvelope.placeVolume(facePlateVol1, offsetFace1); - facePlate1.setPlacement(placedFacePlate1); - PlacedVolume placedFacePlate2 = aEnvelope.placeVolume(facePlateVol2, offsetFace2); - facePlate2.setPlacement(placedFacePlate2); - PlacedVolume placedFacePlate3 = aEnvelope.placeVolume(facePlateVol3, offsetFace3); - facePlate3.setPlacement(placedFacePlate3); - - // Add structural support made of steel at both ends of extHCal - dd4hep::Tube endPlateShape1(dimensions.rmin1(), (dimensions.rmax1() - dSteelSupport), dZEndPlate); - Volume endPlateVol1("endPlateVol1", endPlateShape1, aLcdd.material(xEndPlate.materialStr())); - endPlateVol1.setVisAttributes(aLcdd, xEndPlate.visStr()); - dd4hep::Tube endPlateShape3(dimensions.rmin(), (dimensions.rmax() - dSteelSupport), dZEndPlate); - Volume endPlateVol3("endPlateVol3", endPlateShape3, aLcdd.material(xEndPlate.materialStr())); - endPlateVol3.setVisAttributes(aLcdd, xEndPlate.visStr()); - - // Endplates placed for the extended Barrels in front and in the back to the central Barrel - DetElement endPlatePos(aHCal, "endPlate_" + std::to_string(1 * sign), 0); - dd4hep::Position posOffset(0, 0, sign * (extBarrelOffset3 + dzDetector3 - dZEndPlate)); - PlacedVolume placedEndPlatePos = aEnvelope.placeVolume(endPlateVol3, posOffset); - endPlatePos.setPlacement(placedEndPlatePos); - - DetElement endPlateNeg(aHCal, "endPlate_" + std::to_string(2 * sign), 0); - dd4hep::Position negOffset(0, 0, sign * (extBarrelOffset1 - dzDetector1 + dZEndPlate)); - PlacedVolume placedEndPlateNeg = aEnvelope.placeVolume(endPlateVol1, negOffset); - endPlateNeg.setPlacement(placedEndPlateNeg); - - std::vector layers; - layers.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); - std::vector > seqInLayers; - seqInLayers.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); - std::vector tilesPerLayer; - tilesPerLayer.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); - - // loop over R ("layers") - double layerR = 0.; - for (unsigned int idxLayer = 0; idxLayer < layerDepths1.size(); ++idxLayer) { - // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) - double rminLayer = sensitiveBarrel1Rmin + layerR; - double rmaxLayer = sensitiveBarrel1Rmin + layerR + layerDepths1.at(idxLayer); - layerR += layerDepths1.at(idxLayer); - - //alternate: even layers consist of tile sequence b, odd layer of tile sequence a - unsigned int sequenceIdx = (idxLayer+1) % 2; - - dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); - Volume tileSequenceVolume("HCalECTileSequenceVol1", tileSequenceShape, aLcdd.air()); - - lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - - - dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector1 ); - Volume layerVolume("HCalECLayerVol1", layerShape, aLcdd.air()); - - layerVolume.setVisAttributes(aLcdd.invisible()); - unsigned int idxSubMod = 0; - - dd4hep::Position moduleOffset1 (0,0,sign * extBarrelOffset1); - - dd4hep::PlacedVolume placedLayerVolume = aEnvelope.placeVolume(layerVolume, moduleOffset1); - unsigned int type1 = 0; - if (sign<0) { - type1 = 3; - } - placedLayerVolume.addPhysVolID("type", type1); // First module type=0,3 in front of second +/- - placedLayerVolume.addPhysVolID("layer", idxLayer); - layers.push_back(placedLayerVolume); - - double tileZOffset = - 0.5* dzSequence; - - // first Z loop (tiles that make up a sequence) - for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; - ++xCompColl, ++idxSubMod) { - xml_comp_t xComp = xCompColl; - dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); - - Volume tileVol("HCalECTileVol_"+ xComp.materialStr() - , tileShape, - aLcdd.material(xComp.materialStr())); - tileVol.setVisAttributes(aLcdd, xComp.visStr()); - - dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); - dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); - - if (xComp.isSensitive()) { - tileVol.setSensitiveDetector(sensDet); - tilesPerLayer.push_back(placedTileVol); - } - tileZOffset += xComp.thickness(); + for (std::vector::iterator it = Layers.begin(); it != Layers.end(); ++it){ + xml_comp_t layer = *it; + Dimension layerDimension(layer.dimensions()); + numSequencesR1 += layerDimension.nmodules(); + numSequencesR2 += layerDimension.nModules(); + numSequencesR3 += layerDimension.nPads(); + + for (int nLayer = 0; nLayer < layerDimension.nmodules(); nLayer++){ + moduleDepth1 += layerDimension.dr(); + layerDepths1.push_back(layerDimension.dr()); + } + for (int nLayer = 0; nLayer < layerDimension.nModules(); nLayer++){ + moduleDepth2 += layerDimension.dr(); + layerDepths2.push_back(layerDimension.dr()); + } + for (int nLayer = 0; nLayer < layerDimension.nPads(); nLayer++){ + moduleDepth3 += layerDimension.dr(); + layerDepths3.push_back(layerDimension.dr()); + } } - // second z loop (place sequences in layer) - std::vector seqs; - double zOffset = - dzDetector1 + 0.5 * dzSequence; //2*dZEndPlate + space + 0.5 * dzSequence; - - for (uint numSeq=0; numSeq < numSequencesZ1; numSeq++){ - dd4hep::Position tileSequencePosition(0, 0, zOffset); - dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); - placedTileSequenceVolume.addPhysVolID("row", numSeq); - seqs.push_back(placedTileSequenceVolume); - zOffset += dzSequence; + lLog << MSG::DEBUG << "retrieved number of layers in first Endcap part: " << numSequencesR1 << " , 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: " << numSequencesR2 << " , 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: " << numSequencesR3 << " , which end up to a full module depth in rho of " << moduleDepth3 << " cm" << endmsg; + + lLog << MSG::INFO << "constructing first part EC: with z offset " << extBarrelOffset1 << " cm: "<< numSequencesZ1 << " sequences in Z, " << numSequencesR1 << " layers in Rho, " << numSequencesR1 * numSequencesZ1 << " tiles" << endmsg; + lLog << MSG::INFO << "constructing second part EC: with offset " << extBarrelOffset2 << " cm: " << numSequencesZ2 << " sequences in Z, " << numSequencesR2 << " layers in Rho, " << layerDepths2.size() * numSequencesZ2 << " tiles" << endmsg; + + lLog << MSG::INFO << "constructing third part EC: with offset " << extBarrelOffset3 << " cm: " << numSequencesZ3 << " sequences in Z, " << numSequencesR3 << " layers in Rho, " << layerDepths3.size() * numSequencesZ3 << " tiles" << endmsg; + + lLog << MSG::INFO << "number of channels: " << (numSequencesR1 * numSequencesZ1) + (numSequencesR2 * numSequencesZ2) + (numSequencesR3 * numSequencesZ3) << endmsg; + + // 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; + + lLog << MSG::INFO << "dz third part EC:" << dzDetector2 * 2 << endmsg; + + + for (int iSign = 0; iSign < 2; iSign++){ + int sign; + if(iSign == 0){ + sign = +1; + lLog << MSG::DEBUG << "Placing detector on the positive side: (cm) " << (dimensions.offset() + dimensions.dz()) << endmsg; + } + else{ + sign = -1; + lLog << MSG::DEBUG << "Placing detector on the negative side: (cm) " << -(dimensions.offset() + dimensions.dz()) << endmsg; + } + // Add structural support made of steel inside of HCal + DetElement facePlate1(caloDetElem, "FacePlate_" + std::to_string(1 * sign), 0); + dd4hep::Tube facePlateShape1(dimensions.rmin1(), (sensitiveBarrel1Rmin - space), (dzDetector1 - 2 * dZEndPlate - space)); + Volume facePlateVol1("facePlateVol1", facePlateShape1, lcdd.material(xFacePlate.materialStr())); + facePlateVol1.setVisAttributes(lcdd, xFacePlate.visStr()); + dd4hep::Position offsetFace1(0, 0, sign * extBarrelOffset1); + + // Faceplate for 2nd part of extended Barrel + DetElement facePlate2(caloDetElem, "FacePlate_" + std::to_string(2 * sign), 0); + dd4hep::Tube facePlateShape2(dimensions.rmin2(), (sensitiveBarrel2Rmin - space), + dzDetector2); + Volume facePlateVol2("facePlateVol2", facePlateShape2, lcdd.material(xFacePlate.materialStr())); + facePlateVol2.setVisAttributes(lcdd, xFacePlate.visStr()); + dd4hep::Position offsetFace2(0, 0, sign * extBarrelOffset2); + + // Faceplate for 3rd part of extended Barrel + DetElement facePlate3(caloDetElem, "FacePlate_" + std::to_string(3 * sign), 0); + dd4hep::Tube facePlateShape3(dimensions.rmin(), (sensitiveBarrel3Rmin - space), + (dzDetector3 - 2 * dZEndPlate - space)); + Volume facePlateVol3("facePlateVol3", facePlateShape3, lcdd.material(xFacePlate.materialStr())); + facePlateVol3.setVisAttributes(lcdd, xFacePlate.visStr()); + dd4hep::Position offsetFace3(0, 0, sign * extBarrelOffset3); + + PlacedVolume placedFacePlate1 = envelopeVolume.placeVolume(facePlateVol1, offsetFace1); + facePlate1.setPlacement(placedFacePlate1); + PlacedVolume placedFacePlate2 = envelopeVolume.placeVolume(facePlateVol2, offsetFace2); + facePlate2.setPlacement(placedFacePlate2); + PlacedVolume placedFacePlate3 = envelopeVolume.placeVolume(facePlateVol3, offsetFace3); + facePlate3.setPlacement(placedFacePlate3); + + // Add structural support made of steel at both ends of extHCal + dd4hep::Tube endPlateShape1(dimensions.rmin1(), (dimensions.rmax1() - dSteelSupport), dZEndPlate); + Volume endPlateVol1("endPlateVol1", endPlateShape1, lcdd.material(xEndPlate.materialStr())); + endPlateVol1.setVisAttributes(lcdd, xEndPlate.visStr()); + dd4hep::Tube endPlateShape3(dimensions.rmin(), (dimensions.rmax() - dSteelSupport), dZEndPlate); + Volume endPlateVol3("endPlateVol3", endPlateShape3, lcdd.material(xEndPlate.materialStr())); + endPlateVol3.setVisAttributes(lcdd, xEndPlate.visStr()); + + // Endplates placed for the extended Barrels in front and in the back to the central Barrel + DetElement endPlatePos(caloDetElem, "endPlate_" + std::to_string(1 * sign), 0); + dd4hep::Position posOffset(0, 0, sign * (extBarrelOffset3 + dzDetector3 - dZEndPlate)); + PlacedVolume placedEndPlatePos = envelopeVolume.placeVolume(endPlateVol3, posOffset); + endPlatePos.setPlacement(placedEndPlatePos); + + DetElement endPlateNeg(caloDetElem, "endPlate_" + std::to_string(2 * sign), 0); + dd4hep::Position negOffset(0, 0, sign * (extBarrelOffset1 - dzDetector1 + dZEndPlate)); + PlacedVolume placedEndPlateNeg = envelopeVolume.placeVolume(endPlateVol1, negOffset); + endPlateNeg.setPlacement(placedEndPlateNeg); + + std::vector layers; + layers.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); + std::vector > seqInLayers; + seqInLayers.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); + std::vector tilesPerLayer; + tilesPerLayer.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); + + // loop over R ("layers") + double layerR = 0.; + for (unsigned int idxLayer = 0; idxLayer < layerDepths1.size(); ++idxLayer){ + // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) + double rminLayer = sensitiveBarrel1Rmin + layerR; + double rmaxLayer = sensitiveBarrel1Rmin + layerR + layerDepths1.at(idxLayer); + layerR += layerDepths1.at(idxLayer); + + //alternate: even layers consist of tile sequence b, odd layer of tile sequence a + unsigned int sequenceIdx = (idxLayer+1) % 2; + + dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); + Volume tileSequenceVolume("HCalECTileSequenceVol1", tileSequenceShape, lcdd.air()); + + lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; + + dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector1 ); + Volume layerVolume("HCalECLayerVol1", layerShape, lcdd.air()); + + layerVolume.setVisAttributes(lcdd.invisible()); + unsigned int idxSubMod = 0; + + dd4hep::Position moduleOffset1 (0,0,sign * extBarrelOffset1); + + dd4hep::PlacedVolume placedLayerVolume = envelopeVolume.placeVolume(layerVolume, moduleOffset1); + unsigned int type1 = 0; + if (sign<0){ + type1 = 3; + } + placedLayerVolume.addPhysVolID("type", type1); // First module type=0,3 in front of second +/- + placedLayerVolume.addPhysVolID("layer", idxLayer); + + layers.push_back(placedLayerVolume); + + double tileZOffset = - 0.5* dzSequence; + + // first Z loop (tiles that make up a sequence) + for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; ++xCompColl, ++idxSubMod){ + xml_comp_t xComp = xCompColl; + dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); + + Volume tileVol("HCalECTileVol_"+ xComp.materialStr(), tileShape, lcdd.material(xComp.materialStr())); + tileVol.setVisAttributes(lcdd, xComp.visStr()); + + dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); + dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); + + if (xComp.isSensitive()){ + tileVol.setSensitiveDetector(sensDet); + tilesPerLayer.push_back(placedTileVol); + } + tileZOffset += xComp.thickness(); + } + + // second z loop (place sequences in layer) + std::vector seqs; + double zOffset = - dzDetector1 + 0.5 * dzSequence; //2*dZEndPlate + space + 0.5 * dzSequence; + + for (uint numSeq=0; numSeq < numSequencesZ1; numSeq++){ + dd4hep::Position tileSequencePosition(0, 0, zOffset); + dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); + placedTileSequenceVolume.addPhysVolID("row", numSeq); + seqs.push_back(placedTileSequenceVolume); + zOffset += dzSequence; + } + seqInLayers.push_back(seqs); + } // layers loop + + + layerR = 0.; + // Placement of subWedges in Wedge, 2nd part + for (unsigned int idxLayer = 0; idxLayer < layerDepths2.size(); ++idxLayer){ + // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) + double rminLayer = sensitiveBarrel2Rmin + layerR; + double rmaxLayer = sensitiveBarrel2Rmin + layerR + layerDepths2.at(idxLayer); + layerR += layerDepths2.at(idxLayer); + + //alternate: even layers consist of tile sequence b, odd layer of tile sequence a + unsigned int sequenceIdx = (idxLayer+1) % 2; + + dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); + Volume tileSequenceVolume("HCalECTileSequenceVol2", tileSequenceShape, lcdd.air()); + + lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; + + dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector2); + Volume layerVolume("HCalECLayerVol2", layerShape, lcdd.air()); + + layerVolume.setVisAttributes(lcdd.invisible()); + unsigned int idxSubMod = 0; + + double tileZOffset = - 0.5* dzSequence; + + // first Z loop (tiles that make up a sequence) + for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; ++xCompColl, ++idxSubMod){ + xml_comp_t xComp = xCompColl; + dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); + + Volume tileVol("HCalECTileVol_", tileShape, lcdd.material(xComp.materialStr())); + tileVol.setVisAttributes(lcdd, xComp.visStr()); + + dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); + dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); + + if (xComp.isSensitive()){ + tileVol.setSensitiveDetector(sensDet); + tilesPerLayer.push_back(placedTileVol); + } + tileZOffset += xComp.thickness(); + } // close first Z loop + + // second z loop (place sequences in layer) + std::vector seqs; + double zOffset = - dzDetector2 + 0.5 * dzSequence; //(dzSequence * 0.5); + + for (uint numSeq=0; numSeq < numSequencesZ2; numSeq++){ + dd4hep::Position tileSequencePosition(0, 0, zOffset); + dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); + placedTileSequenceVolume.addPhysVolID("row", numSeq); + seqs.push_back(placedTileSequenceVolume); + zOffset += dzSequence; + } + seqInLayers.push_back(seqs); + + dd4hep::Position moduleOffset2 (0, 0, sign * extBarrelOffset2); + dd4hep::PlacedVolume placedLayerVolume = envelopeVolume.placeVolume(layerVolume, moduleOffset2); + unsigned int type2 = 1; + if (sign<0){ + type2 = 4; + } + placedLayerVolume.addPhysVolID("type", type2); // Second module type=1,4 behind the first +/- + placedLayerVolume.addPhysVolID("layer", layerDepths1.size() + idxLayer); + layers.push_back(placedLayerVolume); + } + + layerR = 0.; + // Placement of subWedges in Wedge, 3th part + for (unsigned int idxLayer = 0; idxLayer < layerDepths3.size(); ++idxLayer){ + // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) + double rminLayer = sensitiveBarrel3Rmin + layerR; + double rmaxLayer = sensitiveBarrel3Rmin + layerR + layerDepths3.at(idxLayer); + layerR += layerDepths3.at(idxLayer); + + //alternate: even layers consist of tile sequence b, odd layer of tile sequence a + unsigned int sequenceIdx = (idxLayer+1) % 2; + + dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); + Volume tileSequenceVolume("HCalECTileSequenceVol3", tileSequenceShape, lcdd.air()); + + lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; + + dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector3); + Volume layerVolume("HCalECLayerVol3", layerShape, lcdd.air()); + + layerVolume.setVisAttributes(lcdd.invisible()); + unsigned int idxSubMod = 0; + + double tileZOffset = - 0.5* dzSequence; + + // first Z loop (tiles that make up a sequence) + for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; ++xCompColl, ++idxSubMod){ + xml_comp_t xComp = xCompColl; + dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); + + Volume tileVol("HCalECTileVol_" , tileShape, lcdd.material(xComp.materialStr())); + tileVol.setVisAttributes(lcdd, xComp.visStr()); + + dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); + dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); + + if (xComp.isSensitive()){ + tileVol.setSensitiveDetector(sensDet); + tilesPerLayer.push_back(placedTileVol); + } + tileZOffset += xComp.thickness(); + } + + // second z loop (place sequences in layer) + std::vector seqs; + double zOffset = - dzDetector3 + 0.5 * dzSequence; //2*dZEndPlate + space + (dzSequence * 0.5); + + for (uint numSeq=0; numSeq < numSequencesZ3; numSeq++){ + dd4hep::Position tileSequencePosition(0, 0, zOffset); + dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); + placedTileSequenceVolume.addPhysVolID("row", numSeq); + seqs.push_back(placedTileSequenceVolume); + zOffset += dzSequence; + } + seqInLayers.push_back(seqs); + + dd4hep::Position moduleOffset3 (0, 0, sign * extBarrelOffset3); + dd4hep::PlacedVolume placedLayerVolume = envelopeVolume.placeVolume(layerVolume, moduleOffset3); + unsigned int type3 = 2; + if (sign<0){ + type3 = 5; + } + placedLayerVolume.addPhysVolID("type", type3); // Second module type=2,5 behind the first +/- + placedLayerVolume.addPhysVolID("layer", layerDepths1.size() + layerDepths2.size() + idxLayer); + layers.push_back(placedLayerVolume); + } // 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; + + // 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++){ + DetElement layerDet(caloDetElem, dd4hep::xml::_toString(sign*(iLayer+1), "layer%d"), sign*(iLayer+1)); + layerDet.setPlacement(layers[iLayer]); + + for (uint iSeq = 0; iSeq < seqInLayers[iLayer].size(); iSeq++){ + DetElement seqDet(layerDet, dd4hep::xml::_toString(iSeq, "seq%d"), sign*(iSeq+1)); + seqDet.setPlacement(seqInLayers[iLayer][iSeq]); + + DetElement tileDet(seqDet, dd4hep::xml::_toString(iSeq, "tile%d"), sign*(iSeq+1)); + tileDet.setPlacement(tilesPerLayer[iLayer]); + } + } + } // for signs loop + + // Place envelope volume + Volume motherVol = lcdd.pickMotherVolume(caloDetElem); + + PlacedVolume placedHCal = motherVol.placeVolume(envelopeVolume); + placedHCal.addPhysVolID("system", xmlDet.id()); + caloDetElem.setPlacement(placedHCal); + + + // Create caloData object + auto caloData = new dd4hep::rec::LayeredCalorimeterData; + caloData->layoutType = dd4hep::rec::LayeredCalorimeterData::EndcapLayout; + caloDetElem.addExtension(caloData); + + caloData->extent[0] = sensitiveBarrel3Rmin; + caloData->extent[1] = sensitiveBarrel3Rmin + moduleDepth3; // + caloData->extent[2] = 0.; // NN: for barrel detectors this is 0 + caloData->extent[3] = dzDetector1 + dzDetector2 + dzDetector3; + + dd4hep::rec::LayeredCalorimeterData::Layer caloLayer; + + for (unsigned int idxLayer = 0; idxLayer < layerDepths1.size(); ++idxLayer) { + const double difference_bet_r1r2 = layerDepths1.at(idxLayer); + + caloLayer.distance = sensitiveBarrel1Rmin; // should this be always the radius of the first layer as it is now? + caloLayer.sensitive_thickness = difference_bet_r1r2; // not really sure what is this variable + caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; + caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; + + caloData->layers.push_back(caloLayer); } - seqInLayers.push_back(seqs); - } - - layerR = 0.; - // Placement of subWedges in Wedge, 2nd part - for (unsigned int idxLayer = 0; idxLayer < layerDepths2.size(); ++idxLayer) { - // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) - double rminLayer = sensitiveBarrel2Rmin + layerR; - double rmaxLayer = sensitiveBarrel2Rmin + layerR + layerDepths2.at(idxLayer); - layerR += layerDepths2.at(idxLayer); + for (unsigned int idxLayer = 0; idxLayer < layerDepths2.size(); ++idxLayer) { + const double difference_bet_r1r2 = layerDepths2.at(idxLayer); - //alternate: even layers consist of tile sequence b, odd layer of tile sequence a - unsigned int sequenceIdx = (idxLayer+1) % 2; + caloLayer.distance = sensitiveBarrel2Rmin; + caloLayer.sensitive_thickness = difference_bet_r1r2; + caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; + caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; - dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); - Volume tileSequenceVolume("HCalECTileSequenceVol2", tileSequenceShape, aLcdd.air()); - - lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - - - dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector2); - Volume layerVolume("HCalECLayerVol2", layerShape, aLcdd.air()); - - layerVolume.setVisAttributes(aLcdd.invisible()); - unsigned int idxSubMod = 0; - - double tileZOffset = - 0.5* dzSequence; - - // first Z loop (tiles that make up a sequence) - for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; - ++xCompColl, ++idxSubMod) { - xml_comp_t xComp = xCompColl; - dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); - - Volume tileVol("HCalECTileVol_" - , tileShape, - aLcdd.material(xComp.materialStr())); - tileVol.setVisAttributes(aLcdd, xComp.visStr()); - - dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); - dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); - - if (xComp.isSensitive()) { - tileVol.setSensitiveDetector(sensDet); - tilesPerLayer.push_back(placedTileVol); - } - tileZOffset += xComp.thickness(); + caloData->layers.push_back(caloLayer); } - // second z loop (place sequences in layer) - std::vector seqs; - double zOffset = - dzDetector2 + 0.5 * dzSequence; //(dzSequence * 0.5); + for (unsigned int idxLayer = 0; idxLayer < layerDepths3.size(); ++idxLayer) { + const double difference_bet_r1r2 = layerDepths3.at(idxLayer); - for (uint numSeq=0; numSeq < numSequencesZ2; numSeq++){ - dd4hep::Position tileSequencePosition(0, 0, zOffset); - dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); - placedTileSequenceVolume.addPhysVolID("row", numSeq); - seqs.push_back(placedTileSequenceVolume); - zOffset += dzSequence; - } - seqInLayers.push_back(seqs); + caloLayer.distance = sensitiveBarrel3Rmin; + caloLayer.sensitive_thickness = difference_bet_r1r2; + caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; + caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; - dd4hep::Position moduleOffset2 (0, 0, sign * extBarrelOffset2); - dd4hep::PlacedVolume placedLayerVolume = aEnvelope.placeVolume(layerVolume, moduleOffset2); - unsigned int type2 = 1; - if (sign<0) { - type2 = 4; - } - placedLayerVolume.addPhysVolID("type", type2); // Second module type=1,4 behind the first +/- - placedLayerVolume.addPhysVolID("layer", layerDepths1.size() + idxLayer); - layers.push_back(placedLayerVolume); - } - - layerR = 0.; - // Placement of subWedges in Wedge, 3th part - for (unsigned int idxLayer = 0; idxLayer < layerDepths3.size(); ++idxLayer) { - // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) - double rminLayer = sensitiveBarrel3Rmin + layerR; - double rmaxLayer = sensitiveBarrel3Rmin + layerR + layerDepths3.at(idxLayer); - layerR += layerDepths3.at(idxLayer); - - //alternate: even layers consist of tile sequence b, odd layer of tile sequence a - unsigned int sequenceIdx = (idxLayer+1) % 2; - - dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); - Volume tileSequenceVolume("HCalECTileSequenceVol3", tileSequenceShape, aLcdd.air()); - - lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - - dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector3); - Volume layerVolume("HCalECLayerVol3", layerShape, aLcdd.air()); - - layerVolume.setVisAttributes(aLcdd.invisible()); - unsigned int idxSubMod = 0; - - double tileZOffset = - 0.5* dzSequence; - - // first Z loop (tiles that make up a sequence) - for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; - ++xCompColl, ++idxSubMod) { - xml_comp_t xComp = xCompColl; - dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); - - Volume tileVol("HCalECTileVol_" - , tileShape, - aLcdd.material(xComp.materialStr())); - tileVol.setVisAttributes(aLcdd, xComp.visStr()); - - dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); - dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); - - if (xComp.isSensitive()) { - tileVol.setSensitiveDetector(sensDet); - tilesPerLayer.push_back(placedTileVol); - } - tileZOffset += xComp.thickness(); + caloData->layers.push_back(caloLayer); } - - // second z loop (place sequences in layer) - std::vector seqs; - double zOffset = - dzDetector3 + 0.5 * dzSequence; //2*dZEndPlate + space + (dzSequence * 0.5); - - for (uint numSeq=0; numSeq < numSequencesZ3; numSeq++){ - dd4hep::Position tileSequencePosition(0, 0, zOffset); - dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); - placedTileSequenceVolume.addPhysVolID("row", numSeq); - seqs.push_back(placedTileSequenceVolume); - zOffset += dzSequence; - } - seqInLayers.push_back(seqs); - - dd4hep::Position moduleOffset3 (0, 0, sign * extBarrelOffset3); - dd4hep::PlacedVolume placedLayerVolume = aEnvelope.placeVolume(layerVolume, moduleOffset3); - unsigned int type3 = 2; - if (sign<0) { - type3 = 5; - } - placedLayerVolume.addPhysVolID("type", type3); // Second module type=2,5 behind the first +/- - placedLayerVolume.addPhysVolID("layer", layerDepths1.size() + layerDepths2.size() + idxLayer); - layers.push_back(placedLayerVolume); - } - - // Placement of DetElements - lLog << MSG::DEBUG << "Layers in r : " << layers.size() << std::endl; - lLog << MSG::DEBUG << "Tiles in layers :" << tilesPerLayer.size() << std::endl; - - for (uint iLayer = 0; iLayer < (layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); iLayer++) { - DetElement layerDet(aHCal, dd4hep::xml::_toString(sign*(iLayer+1), "layer%d"), sign*(iLayer+1)); - layerDet.setPlacement(layers[iLayer]); - - for (uint iSeq = 0; iSeq < seqInLayers[iLayer].size(); iSeq++){ - DetElement seqDet(layerDet, dd4hep::xml::_toString(iSeq, "seq%d"), sign*(iSeq+1)); - seqDet.setPlacement(seqInLayers[iLayer][iSeq]); - - DetElement tileDet(seqDet, dd4hep::xml::_toString(iSeq, "tile%d"), sign*(iSeq+1)); - tileDet.setPlacement(tilesPerLayer[iLayer]); - } - } - -} - -static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4hep::SensitiveDetector sensDet) { - - - xml_det_t xmlDet = xmlElement; - std::string detName = xmlDet.nameStr(); - - // Make DetElement - dd4hep::DetElement hCalEC(detName, xmlDet.id()); - - // Make volume that envelopes the whole barrel; set material to air - Dimension dimensions(xmlDet.dimensions()); - - dd4hep::Tube envelope(dimensions.rmin(), dimensions.rmax1(), (dimensions.v_offset() + dimensions.z_length())); - dd4hep::Tube negative1(dimensions.rmin(), dimensions.rmax1(), (dimensions.offset() - dimensions.width())); - dd4hep::Tube negative2(dimensions.rmin(), dimensions.rmin1(), (dimensions.z_offset() - dimensions.dz())); - dd4hep::Tube negative3(dimensions.rmin(), dimensions.rmin2(), (dimensions.v_offset() - dimensions.z_length())); - dd4hep::SubtractionSolid envelopeShapeTmp1(envelope, negative1); - dd4hep::SubtractionSolid envelopeShapeTmp2(envelopeShapeTmp1, negative2); - dd4hep::SubtractionSolid envelopeShape(envelopeShapeTmp2, negative3); - - Volume envelopeVolume(detName + "_volume", envelopeShape, lcdd.air()); - envelopeVolume.setVisAttributes(lcdd, dimensions.visStr()); - - lLog << MSG::DEBUG << "Placing detector on the positive side: (cm) " << (dimensions.offset() + dimensions.dz()) - << endmsg; - buildEC(lcdd, sensDet, envelopeVolume, hCalEC, xmlElement, 1); - lLog << MSG::DEBUG << "Placing detector on the negative side: (cm) " << -(dimensions.offset() + dimensions.dz()) - << endmsg; - buildEC(lcdd, sensDet, envelopeVolume, hCalEC, xmlElement, -1); - - // Place envelope volume - Volume motherVol = lcdd.pickMotherVolume(hCalEC); - - PlacedVolume placedHCal = motherVol.placeVolume(envelopeVolume); - placedHCal.addPhysVolID("system", xmlDet.id()); - hCalEC.setPlacement(placedHCal); - - return hCalEC; -} -} // namespace hcal - + return caloDetElem; +} +}// namespace det DECLARE_DETELEMENT(CaloThreePartsEndcap_o1_v01, det::createHCalEC) diff --git a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp index 89be7154d..2084146b8 100644 --- a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp @@ -1,6 +1,7 @@ // DD4hep #include "DD4hep/DetFactoryHelper.h" +#include using dd4hep::Volume; using dd4hep::DetElement; @@ -12,11 +13,11 @@ using dd4hep::PlacedVolume; #define endmsg std::endl #define lLog std::cout namespace MSG { -const std::string DEBUG = " Debug: "; -const std::string INFO = " Info: "; +const std::string ERROR = "createHCalTileBarrel ERROR "; +const std::string DEBUG = "createHCalTileBarrel DEBUG "; +const std::string INFO = "createHCalTileBarrel INFO "; } - namespace det { static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep::SensitiveDetector sensDet) { @@ -40,7 +41,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep xml_comp_t xSteelSupport = xmlDet.child(_Unicode(steel_support)); double dSteelSupport = xSteelSupport.thickness(); - lLog << MSG::DEBUG << "steel support thickness: " << dSteelSupport << " [cm]" << endmsg; + lLog << MSG::DEBUG << "steel support thickness (cm): " << dSteelSupport << endmsg; lLog << MSG::DEBUG << "steel support material: " << xSteelSupport.materialStr() << endmsg; double sensitiveBarrelRmin = xDimensions.rmin() + xFacePlate.thickness() + space; @@ -50,17 +51,15 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep // NOTE: This assumes that both have the same dimensions! Dimension sequenceDimensions(sequences[1].dimensions()); double dzSequence = sequenceDimensions.dz(); - lLog << MSG::DEBUG << "sequence thickness " << dzSequence << endmsg; + lLog << MSG::DEBUG << "sequence thickness (cm) " << dzSequence << endmsg; - // calculate the number of modules fitting in Z + // calculate the number of sequences fitting in Z unsigned int numSequencesZ = static_cast((2 * xDimensions.dz() - 2 * dZEndPlate - 2 * space) / dzSequence); - // get all 'layer' children of the 'layers' tag std::vector Layers; - for (xml_coll_t xCompColl(xmlDet.child(_Unicode(layers)), _Unicode(layer)); xCompColl; - ++xCompColl) { - Layers.push_back(xCompColl); + for (xml_coll_t xCompColl(xmlDet.child(_Unicode(layers)), _Unicode(layer)); xCompColl; ++xCompColl) { + Layers.push_back(xCompColl); } unsigned int numSequencesR = 0; double moduleDepth = 0.; @@ -74,21 +73,23 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep layerDepths.push_back(layerDimension.dr()); } } - lLog << MSG::DEBUG << "retrieved number of layers: " << numSequencesR - << " , which end up to a full module depth in rho of " << moduleDepth << endmsg; - lLog << MSG::DEBUG << "retrieved number of layers: " << layerDepths.size() << endmsg; + lLog << MSG::DEBUG << "retrieved number of radial layers: " << numSequencesR + << " , which end up to a full module depth in rho of " << moduleDepth << " cm" << endmsg; + lLog << MSG::DEBUG << "retrieved number of radial layers: " << layerDepths.size() << endmsg; - lLog << MSG::INFO << "constructing: " << numSequencesZ << " rings in Z, " << numSequencesR - << " layers in Rho, " << numSequencesR * numSequencesZ << " tiles" << endmsg; + lLog << MSG::INFO << "constructing: " << numSequencesZ << " sequences in Z, " << numSequencesR + << " radial layers, in total " << numSequencesR * numSequencesZ << " tiles" << endmsg; // Calculate correction along z based on the module size (can only have natural number of modules) double dzDetector = (numSequencesZ * dzSequence) / 2 + dZEndPlate + space; - lLog << MSG::DEBUG << "dzDetector: " << dzDetector << endmsg; - lLog << MSG::INFO << "correction of dz (negative = size reduced):" << dzDetector - xDimensions.dz() << endmsg; + lLog << MSG::DEBUG << "dzDetector (cm): " << dzDetector << endmsg; + lLog << MSG::INFO << "correction of dz in cm (negative = size reduced):" << dzDetector - xDimensions.dz() << endmsg; double rminSupport = sensitiveBarrelRmin + moduleDepth; double rmaxSupport = sensitiveBarrelRmin + moduleDepth + dSteelSupport; + double sensitiveBarrelRmax = sensitiveBarrelRmin + moduleDepth; + ////////////////////// detector building ////////////////////// @@ -102,10 +103,11 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep // top level det element representing whole hcal barrel - DetElement hCal(xmlDet.nameStr(), xmlDet.id()); + DetElement caloDetElem(xmlDet.nameStr(), xmlDet.id()); /// envelope shape dd4hep::Tube envelopeShape(xDimensions.rmin(), xDimensions.rmax(), xDimensions.dz()); + Volume envelopeVolume("HCalEnvelopeVolume", envelopeShape, lcdd.air()); envelopeVolume.setVisAttributes(lcdd, xDimensions.visStr()); @@ -114,7 +116,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep Volume facePlateVol("HCalFacePlateVol", facePlateShape, lcdd.material(xFacePlate.materialStr())); facePlateVol.setVisAttributes(lcdd, xFacePlate.visStr()); PlacedVolume placedFacePlate = envelopeVolume.placeVolume(facePlateVol); - DetElement facePlate_det(hCal, "HCalFacePlate", 0); + DetElement facePlate_det(caloDetElem, "HCalFacePlate", 0); facePlate_det.setPlacement(placedFacePlate); // Add structural support made of steel at both ends of HCal @@ -122,22 +124,21 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep Volume endPlateVol("HCalEndPlateVol", endPlateShape, lcdd.material(xEndPlate.materialStr())); endPlateVol.setVisAttributes(lcdd, xEndPlate.visStr()); - DetElement endPlatePos(hCal, "HCalEndPlatePos", 0); + DetElement endPlatePos(caloDetElem, "HCalEndPlatePos", 0); dd4hep::Position posOffset(0, 0, dzDetector - (dZEndPlate / 2)); PlacedVolume placedEndPlatePos = envelopeVolume.placeVolume(endPlateVol, posOffset); endPlatePos.setPlacement(placedEndPlatePos); - DetElement endPlateNeg(hCal, "HCalEndPlateNeg", 1); + DetElement endPlateNeg(caloDetElem, "HCalEndPlateNeg", 1); dd4hep::Position negOffset(0, 0, -dzDetector + (dZEndPlate / 2)); PlacedVolume placedEndPlateNeg = envelopeVolume.placeVolume(endPlateVol, negOffset); endPlateNeg.setPlacement(placedEndPlateNeg); dd4hep::Tube supportShape(rminSupport, rmaxSupport, (dzDetector - dZEndPlate - space)); - Volume steelSupportVolume("HCalSteelSupportVol", supportShape, - lcdd.material(xSteelSupport.materialStr())); + Volume steelSupportVolume("HCalSteelSupportVol", supportShape, lcdd.material(xSteelSupport.materialStr())); steelSupportVolume.setVisAttributes(lcdd.invisible()); PlacedVolume placedSupport = envelopeVolume.placeVolume(steelSupportVolume); - DetElement support(hCal, "HCalSteelSupport", 0); + DetElement support(caloDetElem, "HCalSteelSupport", 0); support.setPlacement(placedSupport); // double sensitiveBarrelDz = dzDetector - dZEndPlate; @@ -158,7 +159,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); Volume tileSequenceVolume("HCalTileSequenceVol", tileSequenceShape, lcdd.air()); - lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; + lLog << MSG::INFO << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector - dZEndPlate - space ); @@ -176,7 +177,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep double tileZOffset = - 0.5* dzSequence; // first Z loop (tiles that make up a sequence) for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; - ++xCompColl, ++idxSubMod) { + ++xCompColl, ++idxSubMod) { xml_comp_t xComp = xCompColl; dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); @@ -210,7 +211,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep // Place det elements wihtin each other to recover volume positions later via cellID for (uint iLayer = 0; iLayer < numSequencesR; iLayer++) { - DetElement layerDet(hCal, dd4hep::xml::_toString(iLayer, "layer%d"), iLayer); + DetElement layerDet(caloDetElem, dd4hep::xml::_toString(iLayer, "layer%d"), iLayer); layerDet.setPlacement(layers[iLayer]); for (uint iSeq = 0; iSeq < seqInLayers[iLayer].size(); iSeq++){ @@ -223,12 +224,39 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep } // Place envelope (or barrel) volume - Volume motherVol = lcdd.pickMotherVolume(hCal); + Volume motherVol = lcdd.pickMotherVolume(caloDetElem); motherVol.setVisAttributes(lcdd.invisible()); - PlacedVolume placedHCal = motherVol.placeVolume(envelopeVolume); - placedHCal.addPhysVolID("system", hCal.id()); - hCal.setPlacement(placedHCal); - return hCal; + PlacedVolume envelopePhysVol = motherVol.placeVolume(envelopeVolume); + envelopePhysVol.addPhysVolID("system", xmlDet.id()); + caloDetElem.setPlacement(envelopePhysVol); + + + // Create caloData object + auto caloData = new dd4hep::rec::LayeredCalorimeterData; + caloData->layoutType = dd4hep::rec::LayeredCalorimeterData::BarrelLayout; + caloDetElem.addExtension(caloData); + + caloData->extent[0] = sensitiveBarrelRmin; + caloData->extent[1] = sensitiveBarrelRmax; // or r_max ? + caloData->extent[2] = 0.; // NN: for barrel detectors this is 0 + caloData->extent[3] = dzDetector; + + dd4hep::rec::LayeredCalorimeterData::Layer caloLayer; + + for (unsigned int idxLayer = 0; idxLayer < layerDepths.size(); ++idxLayer) { + const double difference_bet_r1r2 = layerDepths.at(idxLayer); + + caloLayer.distance = sensitiveBarrelRmin; // should this be always the radius of the first layer as it is now? + caloLayer.sensitive_thickness = difference_bet_r1r2; // not really sure what is this variable + caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; + caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; + + caloData->layers.push_back(caloLayer); + } + + + return caloDetElem; + } } // namespace hcal From bf09fc11b63c6e8ad653deabbff6a9ce61fa9938 Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Thu, 11 Jul 2024 16:26:30 +0200 Subject: [PATCH 23/59] implemented suggestions from discussion --- .../HCalThreePartsEndcap_o1_v01_geo.cpp | 17 +++++++++++++---- .../calorimeter/HCalTileBarrel_o1_v01_geo.cpp | 17 ++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp index 1baccf00c..e447069f4 100644 --- a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp @@ -92,6 +92,10 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h std::vector layerDepths2 = std::vector(); std::vector layerDepths3 = std::vector(); + std::vector layerInnerRadii1 = std::vector(); + std::vector layerInnerRadii2 = std::vector(); + std::vector layerInnerRadii3 = std::vector(); + // get all 'layer' children of the 'layers' tag std::vector Layers; for (xml_coll_t xCompColl(xmlElement.child(_Unicode(layers)), _Unicode(layer)); xCompColl; ++xCompColl){ @@ -216,6 +220,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h double rminLayer = sensitiveBarrel1Rmin + layerR; double rmaxLayer = sensitiveBarrel1Rmin + layerR + layerDepths1.at(idxLayer); layerR += layerDepths1.at(idxLayer); + layerInnerRadii1.push_back(rminLayer); //alternate: even layers consist of tile sequence b, odd layer of tile sequence a unsigned int sequenceIdx = (idxLayer+1) % 2; @@ -285,6 +290,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h double rminLayer = sensitiveBarrel2Rmin + layerR; double rmaxLayer = sensitiveBarrel2Rmin + layerR + layerDepths2.at(idxLayer); layerR += layerDepths2.at(idxLayer); + layerInnerRadii2.push_back(rminLayer); //alternate: even layers consist of tile sequence b, odd layer of tile sequence a unsigned int sequenceIdx = (idxLayer+1) % 2; @@ -351,6 +357,8 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h double rminLayer = sensitiveBarrel3Rmin + layerR; double rmaxLayer = sensitiveBarrel3Rmin + layerR + layerDepths3.at(idxLayer); layerR += layerDepths3.at(idxLayer); + layerInnerRadii3.push_back(rminLayer); + //alternate: even layers consist of tile sequence b, odd layer of tile sequence a unsigned int sequenceIdx = (idxLayer+1) % 2; @@ -449,11 +457,12 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h dd4hep::rec::LayeredCalorimeterData::Layer caloLayer; + for (unsigned int idxLayer = 0; idxLayer < layerDepths1.size(); ++idxLayer) { const double difference_bet_r1r2 = layerDepths1.at(idxLayer); - caloLayer.distance = sensitiveBarrel1Rmin; // should this be always the radius of the first layer as it is now? - caloLayer.sensitive_thickness = difference_bet_r1r2; // not really sure what is this variable + caloLayer.distance = layerInnerRadii1.at(idxLayer); // radius of the current layer + caloLayer.sensitive_thickness = difference_bet_r1r2; // radial dimension of the current layer caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; @@ -463,7 +472,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h for (unsigned int idxLayer = 0; idxLayer < layerDepths2.size(); ++idxLayer) { const double difference_bet_r1r2 = layerDepths2.at(idxLayer); - caloLayer.distance = sensitiveBarrel2Rmin; + caloLayer.distance = layerInnerRadii2.at(idxLayer); caloLayer.sensitive_thickness = difference_bet_r1r2; caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; @@ -474,7 +483,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h for (unsigned int idxLayer = 0; idxLayer < layerDepths3.size(); ++idxLayer) { const double difference_bet_r1r2 = layerDepths3.at(idxLayer); - caloLayer.distance = sensitiveBarrel3Rmin; + caloLayer.distance = layerInnerRadii3.at(idxLayer); caloLayer.sensitive_thickness = difference_bet_r1r2; caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; diff --git a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp index 2084146b8..98573707a 100644 --- a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp @@ -41,7 +41,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep xml_comp_t xSteelSupport = xmlDet.child(_Unicode(steel_support)); double dSteelSupport = xSteelSupport.thickness(); - lLog << MSG::DEBUG << "steel support thickness (cm): " << dSteelSupport << endmsg; + lLog << MSG::DEBUG << "steel support thickness (cm): " << dSteelSupport / dd4hep::cm << endmsg; lLog << MSG::DEBUG << "steel support material: " << xSteelSupport.materialStr() << endmsg; double sensitiveBarrelRmin = xDimensions.rmin() + xFacePlate.thickness() + space; @@ -51,7 +51,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep // NOTE: This assumes that both have the same dimensions! Dimension sequenceDimensions(sequences[1].dimensions()); double dzSequence = sequenceDimensions.dz(); - lLog << MSG::DEBUG << "sequence thickness (cm) " << dzSequence << endmsg; + lLog << MSG::DEBUG << "sequence thickness (cm) " << dzSequence / dd4hep::cm << endmsg; // calculate the number of sequences fitting in Z unsigned int numSequencesZ = static_cast((2 * xDimensions.dz() - 2 * dZEndPlate - 2 * space) / dzSequence); @@ -64,6 +64,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep unsigned int numSequencesR = 0; double moduleDepth = 0.; std::vector layerDepths = std::vector(); + std::vector layerInnerRadii = std::vector(); for (std::vector::iterator it = Layers.begin(); it != Layers.end(); ++it) { xml_comp_t layer = *it; Dimension layerDimension(layer.dimensions()); @@ -82,7 +83,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep // Calculate correction along z based on the module size (can only have natural number of modules) double dzDetector = (numSequencesZ * dzSequence) / 2 + dZEndPlate + space; - lLog << MSG::DEBUG << "dzDetector (cm): " << dzDetector << endmsg; + lLog << MSG::DEBUG << "dzDetector (cm): " << dzDetector / dd4hep::cm << endmsg; lLog << MSG::INFO << "correction of dz in cm (negative = size reduced):" << dzDetector - xDimensions.dz() << endmsg; double rminSupport = sensitiveBarrelRmin + moduleDepth; @@ -152,15 +153,13 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep double rminLayer = sensitiveBarrelRmin + layerR; double rmaxLayer = sensitiveBarrelRmin + layerR + layerDepths.at(idxLayer); layerR += layerDepths.at(idxLayer); + layerInnerRadii.push_back(rminLayer); //alternate: even layers consist of tile sequence b, odd layer of tile sequence a unsigned int sequenceIdx = idxLayer % 2; dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); - Volume tileSequenceVolume("HCalTileSequenceVol", tileSequenceShape, lcdd.air()); - - lLog << MSG::INFO << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - + Volume tileSequenceVolume("HCalTileSequenceVol", tileSequenceShape, lcdd.air()); dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector - dZEndPlate - space ); Volume layerVolume("HCalLayerVol", layerShape, lcdd.air()); @@ -246,8 +245,8 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep for (unsigned int idxLayer = 0; idxLayer < layerDepths.size(); ++idxLayer) { const double difference_bet_r1r2 = layerDepths.at(idxLayer); - caloLayer.distance = sensitiveBarrelRmin; // should this be always the radius of the first layer as it is now? - caloLayer.sensitive_thickness = difference_bet_r1r2; // not really sure what is this variable + caloLayer.distance = layerInnerRadii.at(idxLayer); // radius of the current layer + caloLayer.sensitive_thickness = difference_bet_r1r2; // radial dimension of the current layer caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; From 405e0a04b02426e4c6b4d852eaee961ef6f0d296 Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Wed, 31 Jul 2024 17:30:17 +0200 Subject: [PATCH 24/59] implement comments and improve code readibility --- .../HCalThreePartsEndcap_o1_v01_geo.cpp | 49 ++++++++++--------- .../calorimeter/HCalTileBarrel_o1_v01_geo.cpp | 22 ++++++--- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp index e447069f4..05d428801 100644 --- a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp @@ -27,7 +27,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h // Make DetElement dd4hep::DetElement caloDetElem(detName, xmlDet.id()); - // Make volume that envelopes the whole barrel; set material to air + // Make volume that envelopes the whole endcap; set material to air Dimension dimensions(xmlDet.dimensions()); dd4hep::Tube envelope(dimensions.rmin(), dimensions.rmax1(), (dimensions.v_offset() + dimensions.z_length())); @@ -46,7 +46,6 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h Dimension sensDetType = xmlElement.child(_Unicode(sensitive)); sensDet.setType(sensDetType.typeStr()); - // Dimension dimensions(xmlElement.child(_Unicode(dimensions))); xml_comp_t xEndPlate = xmlElement.child(_Unicode(end_plate)); double dZEndPlate = xEndPlate.thickness() / 2.; xml_comp_t xFacePlate = xmlElement.child(_Unicode(face_plate)); @@ -70,9 +69,19 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h // Hard-coded assumption that we have two different sequences for the modules std::vector sequences = {xmlElement.child(_Unicode(sequence_a)), xmlElement.child(_Unicode(sequence_b))}; - // NOTE: This assumes that both have the same dimensions! - Dimension sequenceDimensions(sequences[1].dimensions()); - double dzSequence = sequenceDimensions.dz(); + // 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; + 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; + 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; // calculate the number of modules fitting in Z @@ -87,7 +96,6 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h double moduleDepth2 = 0.; double moduleDepth3 = 0.; - // MM: using layers and Layers is not very fortunate std::vector layerDepths1 = std::vector(); std::vector layerDepths2 = std::vector(); std::vector layerDepths3 = std::vector(); @@ -96,24 +104,19 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h std::vector layerInnerRadii2 = std::vector(); std::vector layerInnerRadii3 = std::vector(); - // get all 'layer' children of the 'layers' tag - std::vector Layers; + // iterating over XML elements to retrieve all child elements of 'layers' for (xml_coll_t xCompColl(xmlElement.child(_Unicode(layers)), _Unicode(layer)); xCompColl; ++xCompColl){ - Layers.push_back(xCompColl); - } - - for (std::vector::iterator it = Layers.begin(); it != Layers.end(); ++it){ - xml_comp_t layer = *it; - Dimension layerDimension(layer.dimensions()); + xml_comp_t currentLayer = xCompColl; + Dimension layerDimension(currentLayer.dimensions()); numSequencesR1 += layerDimension.nmodules(); - numSequencesR2 += layerDimension.nModules(); + numSequencesR2 += layerDimension.nsegments(); numSequencesR3 += layerDimension.nPads(); for (int nLayer = 0; nLayer < layerDimension.nmodules(); nLayer++){ moduleDepth1 += layerDimension.dr(); layerDepths1.push_back(layerDimension.dr()); } - for (int nLayer = 0; nLayer < layerDimension.nModules(); nLayer++){ + for (int nLayer = 0; nLayer < layerDimension.nsegments(); nLayer++){ moduleDepth2 += layerDimension.dr(); layerDepths2.push_back(layerDimension.dr()); } @@ -147,15 +150,15 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h lLog << MSG::INFO << "dz third part EC:" << dzDetector2 * 2 << endmsg; - for (int iSign = 0; iSign < 2; iSign++){ + for (int iSign = -1; iSign < 2; iSign+=2){ int sign; - if(iSign == 0){ - sign = +1; - lLog << MSG::DEBUG << "Placing detector on the positive side: (cm) " << (dimensions.offset() + dimensions.dz()) << endmsg; + if(iSign < 0){ + sign = -1; + lLog << MSG::DEBUG << "Placing detector on the negative side: (cm) " << -(dimensions.offset() + dimensions.dz()) << endmsg; } else{ - sign = -1; - lLog << MSG::DEBUG << "Placing detector on the negative side: (cm) " << -(dimensions.offset() + dimensions.dz()) << endmsg; + sign = +1; + lLog << MSG::DEBUG << "Placing detector on the positive side: (cm) " << (dimensions.offset() + dimensions.dz()) << endmsg; } // Add structural support made of steel inside of HCal DetElement facePlate1(caloDetElem, "FacePlate_" + std::to_string(1 * sign), 0); @@ -441,7 +444,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h Volume motherVol = lcdd.pickMotherVolume(caloDetElem); PlacedVolume placedHCal = motherVol.placeVolume(envelopeVolume); - placedHCal.addPhysVolID("system", xmlDet.id()); + placedHCal.addPhysVolID("system", caloDetElem.id()); caloDetElem.setPlacement(placedHCal); diff --git a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp index 98573707a..2a8815251 100644 --- a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp @@ -48,10 +48,20 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep // Hard-coded assumption that we have two different sequences for the modules std::vector sequences = {xmlDet.child(_Unicode(sequence_a)), xmlDet.child(_Unicode(sequence_b))}; - // NOTE: This assumes that both have the same dimensions! - Dimension sequenceDimensions(sequences[1].dimensions()); - double dzSequence = sequenceDimensions.dz(); - lLog << MSG::DEBUG << "sequence thickness (cm) " << dzSequence / dd4hep::cm << endmsg; + // 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; + 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; + 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; // calculate the number of sequences fitting in Z unsigned int numSequencesZ = static_cast((2 * xDimensions.dz() - 2 * dZEndPlate - 2 * space) / dzSequence); @@ -226,7 +236,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep Volume motherVol = lcdd.pickMotherVolume(caloDetElem); motherVol.setVisAttributes(lcdd.invisible()); PlacedVolume envelopePhysVol = motherVol.placeVolume(envelopeVolume); - envelopePhysVol.addPhysVolID("system", xmlDet.id()); + envelopePhysVol.addPhysVolID("system", caloDetElem.id()); caloDetElem.setPlacement(envelopePhysVol); @@ -236,7 +246,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep caloDetElem.addExtension(caloData); caloData->extent[0] = sensitiveBarrelRmin; - caloData->extent[1] = sensitiveBarrelRmax; // or r_max ? + caloData->extent[1] = sensitiveBarrelRmax; caloData->extent[2] = 0.; // NN: for barrel detectors this is 0 caloData->extent[3] = dzDetector; From 036ea5a0814c9e2176035cf7f2e12b12b286891d Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Fri, 2 Aug 2024 20:46:43 +0200 Subject: [PATCH 25/59] fix failing test and remove unused phi segmentation --- .../ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml | 6 +++--- .../ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml | 6 +++--- detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml index c5cbe72a7..5531d85db 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml @@ -71,7 +71,7 @@ @@ -79,7 +79,7 @@ @@ -87,7 +87,7 @@ diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml index c5cbe72a7..5531d85db 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml @@ -71,7 +71,7 @@ @@ -79,7 +79,7 @@ @@ -87,7 +87,7 @@ diff --git a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp index 05d428801..416570235 100644 --- a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp @@ -397,7 +397,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h tileZOffset += xComp.thickness(); } - // second z loop (place sequences in layer) + // second z loop (place sequences in layer) std::vector seqs; double zOffset = - dzDetector3 + 0.5 * dzSequence; //2*dZEndPlate + space + (dzSequence * 0.5); @@ -460,10 +460,10 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h dd4hep::rec::LayeredCalorimeterData::Layer caloLayer; - + // IMPORTANT: the information below is used to calculate the cell position in CellPositionsHCalPhiThetaSegTool in k4RecCalorimeter + // if the definition distance or sensitive_thickness is modified, one also needs to modify CellPositionsHCalPhiThetaSegTool for (unsigned int idxLayer = 0; idxLayer < layerDepths1.size(); ++idxLayer) { const double difference_bet_r1r2 = layerDepths1.at(idxLayer); - caloLayer.distance = layerInnerRadii1.at(idxLayer); // radius of the current layer caloLayer.sensitive_thickness = difference_bet_r1r2; // radial dimension of the current layer caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; From 4f675df3ab88fcd8f3da31a7b17fd30d319975fc Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Mon, 5 Aug 2024 21:06:47 +0200 Subject: [PATCH 26/59] fix endcap bitfields and improve readibility --- .../HCalThreePartsEndcap_o1_v01_geo.cpp | 32 +++++++++---------- .../calorimeter/HCalTileBarrel_o1_v01_geo.cpp | 12 +++---- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp index 416570235..88af1f401 100644 --- a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp @@ -89,9 +89,9 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h unsigned int numSequencesZ2 = static_cast((2 * dimensions.dz() - 2 * dZEndPlate - space) / dzSequence); unsigned int numSequencesZ3 = static_cast((2 * dimensions.z_length() - 2 * dZEndPlate - space) / dzSequence); - unsigned int numSequencesR1 = 0; - unsigned int numSequencesR2 = 0; - unsigned int numSequencesR3 = 0; + unsigned int numLayersR1 = 0; + unsigned int numLayersR2 = 0; + unsigned int numLayersR3 = 0; double moduleDepth1 = 0.; double moduleDepth2 = 0.; double moduleDepth3 = 0.; @@ -108,9 +108,9 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h for (xml_coll_t xCompColl(xmlElement.child(_Unicode(layers)), _Unicode(layer)); xCompColl; ++xCompColl){ xml_comp_t currentLayer = xCompColl; Dimension layerDimension(currentLayer.dimensions()); - numSequencesR1 += layerDimension.nmodules(); - numSequencesR2 += layerDimension.nsegments(); - numSequencesR3 += layerDimension.nPads(); + numLayersR1 += layerDimension.nmodules(); + numLayersR2 += layerDimension.nsegments(); + numLayersR3 += layerDimension.nPads(); for (int nLayer = 0; nLayer < layerDimension.nmodules(); nLayer++){ moduleDepth1 += layerDimension.dr(); @@ -126,16 +126,16 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h } } - lLog << MSG::DEBUG << "retrieved number of layers in first Endcap part: " << numSequencesR1 << " , 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: " << numSequencesR2 << " , 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: " << numSequencesR3 << " , which end up to a full module depth in rho of " << moduleDepth3 << " cm" << endmsg; + 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; - lLog << MSG::INFO << "constructing first part EC: with z offset " << extBarrelOffset1 << " cm: "<< numSequencesZ1 << " sequences in Z, " << numSequencesR1 << " layers in Rho, " << numSequencesR1 * numSequencesZ1 << " tiles" << endmsg; - lLog << MSG::INFO << "constructing second part EC: with offset " << extBarrelOffset2 << " cm: " << numSequencesZ2 << " sequences in Z, " << numSequencesR2 << " layers in Rho, " << layerDepths2.size() * numSequencesZ2 << " tiles" << endmsg; + 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; - lLog << MSG::INFO << "constructing third part EC: with offset " << extBarrelOffset3 << " cm: " << numSequencesZ3 << " sequences in Z, " << numSequencesR3 << " layers in Rho, " << layerDepths3.size() * numSequencesZ3 << " tiles" << endmsg; + 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: " << (numSequencesR1 * numSequencesZ1) + (numSequencesR2 * numSequencesZ2) + (numSequencesR3 * numSequencesZ3) << endmsg; + lLog << MSG::INFO << "number of channels: " << (numLayersR1 * numSequencesZ1) + (numLayersR2 * numSequencesZ2) + (numLayersR3 * numSequencesZ3) << endmsg; // Calculate correction along z based on the module size (can only have natural number of modules) double dzDetector1 = (numSequencesZ1 * dzSequence) / 2 + 2 * dZEndPlate + space; @@ -147,7 +147,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h 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; - lLog << MSG::INFO << "dz third part EC:" << dzDetector2 * 2 << endmsg; + lLog << MSG::INFO << "dz third part EC:" << dzDetector3 * 2 << endmsg; for (int iSign = -1; iSign < 2; iSign+=2){ @@ -232,7 +232,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h Volume tileSequenceVolume("HCalECTileSequenceVol1", tileSequenceShape, lcdd.air()); lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - + dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector1 ); Volume layerVolume("HCalECLayerVol1", layerShape, lcdd.air()); @@ -474,7 +474,6 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h for (unsigned int idxLayer = 0; idxLayer < layerDepths2.size(); ++idxLayer) { const double difference_bet_r1r2 = layerDepths2.at(idxLayer); - caloLayer.distance = layerInnerRadii2.at(idxLayer); caloLayer.sensitive_thickness = difference_bet_r1r2; caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; @@ -485,7 +484,6 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h for (unsigned int idxLayer = 0; idxLayer < layerDepths3.size(); ++idxLayer) { const double difference_bet_r1r2 = layerDepths3.at(idxLayer); - caloLayer.distance = layerInnerRadii3.at(idxLayer); caloLayer.sensitive_thickness = difference_bet_r1r2; caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; diff --git a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp index 2a8815251..c6f359dd3 100644 --- a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp @@ -71,25 +71,25 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep for (xml_coll_t xCompColl(xmlDet.child(_Unicode(layers)), _Unicode(layer)); xCompColl; ++xCompColl) { Layers.push_back(xCompColl); } - unsigned int numSequencesR = 0; + unsigned int numLayersR = 0; double moduleDepth = 0.; std::vector layerDepths = std::vector(); std::vector layerInnerRadii = std::vector(); for (std::vector::iterator it = Layers.begin(); it != Layers.end(); ++it) { xml_comp_t layer = *it; Dimension layerDimension(layer.dimensions()); - numSequencesR += layerDimension.nModules(); + numLayersR += layerDimension.nModules(); for (int nLayer = 0; nLayer < layerDimension.nModules(); nLayer++) { moduleDepth += layerDimension.dr(); layerDepths.push_back(layerDimension.dr()); } } - lLog << MSG::DEBUG << "retrieved number of radial layers: " << numSequencesR + lLog << MSG::DEBUG << "retrieved number of radial layers: " << numLayersR << " , which end up to a full module depth in rho of " << moduleDepth << " cm" << endmsg; lLog << MSG::DEBUG << "retrieved number of radial layers: " << layerDepths.size() << endmsg; - lLog << MSG::INFO << "constructing: " << numSequencesZ << " sequences in Z, " << numSequencesR - << " radial layers, in total " << numSequencesR * numSequencesZ << " tiles" << endmsg; + lLog << MSG::INFO << "constructing: " << numSequencesZ << " sequences in Z, " << numLayersR + << " radial layers, in total " << numLayersR * numSequencesZ << " tiles" << endmsg; // Calculate correction along z based on the module size (can only have natural number of modules) double dzDetector = (numSequencesZ * dzSequence) / 2 + dZEndPlate + space; @@ -219,7 +219,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep } // Place det elements wihtin each other to recover volume positions later via cellID - for (uint iLayer = 0; iLayer < numSequencesR; iLayer++) { + for (uint iLayer = 0; iLayer < numLayersR; iLayer++) { DetElement layerDet(caloDetElem, dd4hep::xml::_toString(iLayer, "layer%d"), iLayer); layerDet.setPlacement(layers[iLayer]); From 464ae47c70419d106c16acbef9fc6e2f556a362f Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Wed, 7 Aug 2024 17:31:59 +0200 Subject: [PATCH 27/59] keep ALLEGRO v03 xml file unchanged --- .../FCCee_HCalEndcaps_ThreeParts_TileCal.xml | 6 +- .../HCalEndcaps_ThreeParts_TileCal.xml | 6 +- .../HCalEndcaps_ThreeParts_TileCal_v02.xml | 33 +- .../HCalThreePartsEndcap_o1_v01_geo.cpp | 910 +++++++++--------- .../HCalThreePartsEndcap_o1_v02_geo.cpp | 1 - 5 files changed, 463 insertions(+), 493 deletions(-) diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml index 5531d85db..c5cbe72a7 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v01/FCCee_HCalEndcaps_ThreeParts_TileCal.xml @@ -71,7 +71,7 @@ @@ -79,7 +79,7 @@ @@ -87,7 +87,7 @@ diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml index 5531d85db..c5cbe72a7 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/HCalEndcaps_ThreeParts_TileCal.xml @@ -71,7 +71,7 @@ @@ -79,7 +79,7 @@ @@ -87,7 +87,7 @@ diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalEndcaps_ThreeParts_TileCal_v02.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalEndcaps_ThreeParts_TileCal_v02.xml index 06fa8d510..ea48314a7 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalEndcaps_ThreeParts_TileCal_v02.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalEndcaps_ThreeParts_TileCal_v02.xml @@ -44,19 +44,20 @@ - - system:4,type:3,layer:6,row:11,theta:11,phi:10 + + system:4,type:2,layer:5,row:9,eta:11,phi:10 - - - system:4,type:3,layer:6,theta:11,phi:10 + + + system:4,type:2,layer:4,eta:11,phi:10 + + + + + system:4,type:2,layer:5,row:9,eta:10,phi:10 - - @@ -69,25 +70,25 @@ diff --git a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp index 88af1f401..34544c2e2 100644 --- a/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalThreePartsEndcap_o1_v01_geo.cpp @@ -1,497 +1,467 @@ // DD4hep #include "DD4hep/DetFactoryHelper.h" -#include // 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 "; +const std::string DEBUG = " Debug: "; +const std::string INFO = " Info: "; } using dd4hep::Volume; using dd4hep::DetElement; using dd4hep::xml::Dimension; using dd4hep::PlacedVolume; -using xml_comp_t = dd4hep::xml::Component; -using xml_det_t = dd4hep::xml::DetElement; -using xml_h = dd4hep::xml::Handle_t; namespace det { -static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4hep::SensitiveDetector sensDet){ - xml_det_t xmlDet = xmlElement; - std::string detName = xmlDet.nameStr(); - - // Make DetElement - dd4hep::DetElement caloDetElem(detName, xmlDet.id()); - - // Make volume that envelopes the whole endcap; set material to air - Dimension dimensions(xmlDet.dimensions()); - - dd4hep::Tube envelope(dimensions.rmin(), dimensions.rmax1(), (dimensions.v_offset() + dimensions.z_length())); - dd4hep::Tube negative1(dimensions.rmin(), dimensions.rmax1(), (dimensions.offset() - dimensions.width())); - dd4hep::Tube negative2(dimensions.rmin(), dimensions.rmin1(), (dimensions.z_offset() - dimensions.dz())); - dd4hep::Tube negative3(dimensions.rmin(), dimensions.rmin2(), (dimensions.v_offset() - dimensions.z_length())); - - dd4hep::SubtractionSolid envelopeShapeTmp1(envelope, negative1); - dd4hep::SubtractionSolid envelopeShapeTmp2(envelopeShapeTmp1, negative2); - dd4hep::SubtractionSolid envelopeShape(envelopeShapeTmp2, negative3); - - Volume envelopeVolume(detName + "_volume", envelopeShape, lcdd.air()); - envelopeVolume.setVisAttributes(lcdd, dimensions.visStr()); - - // Set sensitive detector type - Dimension sensDetType = xmlElement.child(_Unicode(sensitive)); - sensDet.setType(sensDetType.typeStr()); - - xml_comp_t xEndPlate = xmlElement.child(_Unicode(end_plate)); - double dZEndPlate = xEndPlate.thickness() / 2.; - xml_comp_t xFacePlate = xmlElement.child(_Unicode(face_plate)); - double dRhoFacePlate = xFacePlate.thickness() / 2.; - xml_comp_t xSpace = xmlElement.child(_Unicode(plate_space)); // to avoid overlaps - 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; - - // Calculate sensitive barrel dimensions - double sensitiveBarrel1Rmin = dimensions.rmin1() + 2 * dRhoFacePlate + space; - double sensitiveBarrel2Rmin = dimensions.rmin2() + 2 * dRhoFacePlate + space; - double sensitiveBarrel3Rmin = dimensions.rmin() + 2 * dRhoFacePlate + space; - - // Offset in z is given as distance from 0 to the middle of the Calorimeter volume - double extBarrelOffset1 = dimensions.offset(); - double extBarrelOffset2 = dimensions.z_offset(); - double extBarrelOffset3 = dimensions.v_offset(); - - // Hard-coded assumption that we have two different sequences for the modules - std::vector 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; - throw std::runtime_error("Missing sequence_a or sequence_b in the xml file."); +void buildEC(dd4hep::Detector& aLcdd, dd4hep::SensitiveDetector& aSensDet, dd4hep::Volume& aEnvelope, + dd4hep::DetElement& aHCal, xml_det_t aXmlElement, int sign) { + + dd4hep::SensitiveDetector sensDet = aSensDet; + Dimension sensDetType = aXmlElement.child(_Unicode(sensitive)); + sensDet.setType(sensDetType.typeStr()); + + Dimension dimensions(aXmlElement.child(_Unicode(dimensions))); + xml_comp_t xEndPlate = aXmlElement.child(_Unicode(end_plate)); + double dZEndPlate = xEndPlate.thickness() / 2.; + xml_comp_t xFacePlate = aXmlElement.child(_Unicode(face_plate)); + double dRhoFacePlate = xFacePlate.thickness() / 2.; + xml_comp_t xSpace = aXmlElement.child(_Unicode(plate_space)); // to avoid overlaps + double space = xSpace.thickness(); + xml_comp_t xSteelSupport = aXmlElement.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; + + double sensitiveBarrel1Rmin = dimensions.rmin1() + 2 * dRhoFacePlate + space; + double sensitiveBarrel2Rmin = dimensions.rmin2() + 2 * dRhoFacePlate + space; + double sensitiveBarrel3Rmin = dimensions.rmin() + 2 * dRhoFacePlate + space; + + // Offset in z is given as distance from 0 to the middle of the Calorimeter volume + double extBarrelOffset1 = dimensions.offset(); + double extBarrelOffset2 = dimensions.z_offset(); + double extBarrelOffset3 = dimensions.v_offset(); + + // Hard-coded assumption that we have two different sequences for the modules + std::vector sequences = {aXmlElement.child(_Unicode(sequence_a)), aXmlElement.child(_Unicode(sequence_b))}; + // NOTE: This assumes that both have the same dimensions! + Dimension sequenceDimensions(sequences[1].dimensions()); + double dzSequence = sequenceDimensions.dz(); + lLog << MSG::DEBUG << "sequence thickness " << dzSequence << endmsg; + + // calculate the number of modules fitting in Z + unsigned int numSequencesZ1 = static_cast((2 * dimensions.width() - 2 * dZEndPlate - space) / dzSequence); + unsigned int numSequencesZ2 = static_cast((2 * dimensions.dz() - 2 * dZEndPlate - space) / dzSequence); + unsigned int numSequencesZ3 = static_cast((2 * dimensions.z_length() - 2 * dZEndPlate - space) / dzSequence); + + unsigned int numSequencesR1 = 0; + unsigned int numSequencesR2 = 0; + unsigned int numSequencesR3 = 0; + double moduleDepth1 = 0.; + double moduleDepth2 = 0.; + double moduleDepth3 = 0.; + std::vector layerDepths1 = std::vector(); + std::vector layerDepths2 = std::vector(); + std::vector layerDepths3 = std::vector(); + + // get all 'layer' children of the 'layers' tag + std::vector Layers; + for (xml_coll_t xCompColl(aXmlElement.child(_Unicode(layers)), _Unicode(layer)); xCompColl; + ++xCompColl) { + Layers.push_back(xCompColl); + } + + for (std::vector::iterator it = Layers.begin(); it != Layers.end(); ++it) { + xml_comp_t layer = *it; + Dimension layerDimension(layer.dimensions()); + numSequencesR1 += layerDimension.nmodules(); + numSequencesR2 += layerDimension.nModules(); + numSequencesR3 += layerDimension.nPads(); + for (int nLayer = 0; nLayer < layerDimension.nmodules(); nLayer++) { + moduleDepth1 += layerDimension.dr(); + layerDepths1.push_back(layerDimension.dr()); } - // 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; - throw std::runtime_error("The dimensions of the sequence_a and sequence_b do not match."); + for (int nLayer = 0; nLayer < layerDimension.nModules(); nLayer++) { + moduleDepth2 += layerDimension.dr(); + layerDepths2.push_back(layerDimension.dr()); } - double dzSequence = dimensionsB.dz(); - lLog << MSG::DEBUG << "sequence thickness " << dzSequence << endmsg; - - // calculate the number of modules fitting in Z - unsigned int numSequencesZ1 = static_cast((2 * dimensions.width() - 2 * dZEndPlate - space) / dzSequence); - unsigned int numSequencesZ2 = static_cast((2 * dimensions.dz() - 2 * dZEndPlate - space) / dzSequence); - unsigned int numSequencesZ3 = static_cast((2 * dimensions.z_length() - 2 * dZEndPlate - space) / dzSequence); - - unsigned int numLayersR1 = 0; - unsigned int numLayersR2 = 0; - unsigned int numLayersR3 = 0; - double moduleDepth1 = 0.; - double moduleDepth2 = 0.; - double moduleDepth3 = 0.; - - std::vector layerDepths1 = std::vector(); - std::vector layerDepths2 = std::vector(); - std::vector layerDepths3 = std::vector(); - - std::vector layerInnerRadii1 = std::vector(); - std::vector layerInnerRadii2 = std::vector(); - std::vector layerInnerRadii3 = std::vector(); - - // iterating over XML elements to retrieve all child elements of 'layers' - for (xml_coll_t xCompColl(xmlElement.child(_Unicode(layers)), _Unicode(layer)); xCompColl; ++xCompColl){ - xml_comp_t currentLayer = xCompColl; - Dimension layerDimension(currentLayer.dimensions()); - numLayersR1 += layerDimension.nmodules(); - numLayersR2 += layerDimension.nsegments(); - numLayersR3 += layerDimension.nPads(); - - for (int nLayer = 0; nLayer < layerDimension.nmodules(); nLayer++){ - moduleDepth1 += layerDimension.dr(); - layerDepths1.push_back(layerDimension.dr()); - } - for (int nLayer = 0; nLayer < layerDimension.nsegments(); nLayer++){ - moduleDepth2 += layerDimension.dr(); - layerDepths2.push_back(layerDimension.dr()); - } - for (int nLayer = 0; nLayer < layerDimension.nPads(); nLayer++){ - moduleDepth3 += layerDimension.dr(); - layerDepths3.push_back(layerDimension.dr()); - } + for (int nLayer = 0; nLayer < layerDimension.nPads(); nLayer++) { + moduleDepth3 += layerDimension.dr(); + layerDepths3.push_back(layerDimension.dr()); } - - 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; - - 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; - - 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; - - // 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; - - lLog << MSG::INFO << "dz third part EC:" << dzDetector3 * 2 << endmsg; - - - 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; - } - else{ - sign = +1; - lLog << MSG::DEBUG << "Placing detector on the positive side: (cm) " << (dimensions.offset() + dimensions.dz()) << endmsg; - } - // Add structural support made of steel inside of HCal - DetElement facePlate1(caloDetElem, "FacePlate_" + std::to_string(1 * sign), 0); - dd4hep::Tube facePlateShape1(dimensions.rmin1(), (sensitiveBarrel1Rmin - space), (dzDetector1 - 2 * dZEndPlate - space)); - Volume facePlateVol1("facePlateVol1", facePlateShape1, lcdd.material(xFacePlate.materialStr())); - facePlateVol1.setVisAttributes(lcdd, xFacePlate.visStr()); - dd4hep::Position offsetFace1(0, 0, sign * extBarrelOffset1); - - // Faceplate for 2nd part of extended Barrel - DetElement facePlate2(caloDetElem, "FacePlate_" + std::to_string(2 * sign), 0); - dd4hep::Tube facePlateShape2(dimensions.rmin2(), (sensitiveBarrel2Rmin - space), - dzDetector2); - Volume facePlateVol2("facePlateVol2", facePlateShape2, lcdd.material(xFacePlate.materialStr())); - facePlateVol2.setVisAttributes(lcdd, xFacePlate.visStr()); - dd4hep::Position offsetFace2(0, 0, sign * extBarrelOffset2); - - // Faceplate for 3rd part of extended Barrel - DetElement facePlate3(caloDetElem, "FacePlate_" + std::to_string(3 * sign), 0); - dd4hep::Tube facePlateShape3(dimensions.rmin(), (sensitiveBarrel3Rmin - space), - (dzDetector3 - 2 * dZEndPlate - space)); - Volume facePlateVol3("facePlateVol3", facePlateShape3, lcdd.material(xFacePlate.materialStr())); - facePlateVol3.setVisAttributes(lcdd, xFacePlate.visStr()); - dd4hep::Position offsetFace3(0, 0, sign * extBarrelOffset3); - - PlacedVolume placedFacePlate1 = envelopeVolume.placeVolume(facePlateVol1, offsetFace1); - facePlate1.setPlacement(placedFacePlate1); - PlacedVolume placedFacePlate2 = envelopeVolume.placeVolume(facePlateVol2, offsetFace2); - facePlate2.setPlacement(placedFacePlate2); - PlacedVolume placedFacePlate3 = envelopeVolume.placeVolume(facePlateVol3, offsetFace3); - facePlate3.setPlacement(placedFacePlate3); - - // Add structural support made of steel at both ends of extHCal - dd4hep::Tube endPlateShape1(dimensions.rmin1(), (dimensions.rmax1() - dSteelSupport), dZEndPlate); - Volume endPlateVol1("endPlateVol1", endPlateShape1, lcdd.material(xEndPlate.materialStr())); - endPlateVol1.setVisAttributes(lcdd, xEndPlate.visStr()); - dd4hep::Tube endPlateShape3(dimensions.rmin(), (dimensions.rmax() - dSteelSupport), dZEndPlate); - Volume endPlateVol3("endPlateVol3", endPlateShape3, lcdd.material(xEndPlate.materialStr())); - endPlateVol3.setVisAttributes(lcdd, xEndPlate.visStr()); - - // Endplates placed for the extended Barrels in front and in the back to the central Barrel - DetElement endPlatePos(caloDetElem, "endPlate_" + std::to_string(1 * sign), 0); - dd4hep::Position posOffset(0, 0, sign * (extBarrelOffset3 + dzDetector3 - dZEndPlate)); - PlacedVolume placedEndPlatePos = envelopeVolume.placeVolume(endPlateVol3, posOffset); - endPlatePos.setPlacement(placedEndPlatePos); - - DetElement endPlateNeg(caloDetElem, "endPlate_" + std::to_string(2 * sign), 0); - dd4hep::Position negOffset(0, 0, sign * (extBarrelOffset1 - dzDetector1 + dZEndPlate)); - PlacedVolume placedEndPlateNeg = envelopeVolume.placeVolume(endPlateVol1, negOffset); - endPlateNeg.setPlacement(placedEndPlateNeg); - - std::vector layers; - layers.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); - std::vector > seqInLayers; - seqInLayers.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); - std::vector tilesPerLayer; - tilesPerLayer.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); - - // loop over R ("layers") - double layerR = 0.; - for (unsigned int idxLayer = 0; idxLayer < layerDepths1.size(); ++idxLayer){ - // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) - double rminLayer = sensitiveBarrel1Rmin + layerR; - double rmaxLayer = sensitiveBarrel1Rmin + layerR + layerDepths1.at(idxLayer); - layerR += layerDepths1.at(idxLayer); - layerInnerRadii1.push_back(rminLayer); - - //alternate: even layers consist of tile sequence b, odd layer of tile sequence a - unsigned int sequenceIdx = (idxLayer+1) % 2; - - dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); - Volume tileSequenceVolume("HCalECTileSequenceVol1", tileSequenceShape, lcdd.air()); - - lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - - dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector1 ); - Volume layerVolume("HCalECLayerVol1", layerShape, lcdd.air()); - - layerVolume.setVisAttributes(lcdd.invisible()); - unsigned int idxSubMod = 0; - - dd4hep::Position moduleOffset1 (0,0,sign * extBarrelOffset1); - - dd4hep::PlacedVolume placedLayerVolume = envelopeVolume.placeVolume(layerVolume, moduleOffset1); - unsigned int type1 = 0; - if (sign<0){ - type1 = 3; - } - placedLayerVolume.addPhysVolID("type", type1); // First module type=0,3 in front of second +/- - placedLayerVolume.addPhysVolID("layer", idxLayer); - - layers.push_back(placedLayerVolume); + } + + lLog << MSG::DEBUG << "retrieved number of layers in first Endcap part: " << numSequencesR1 + << " , which end up to a full module depth in rho of " << moduleDepth1 << endmsg; + lLog << MSG::DEBUG << "retrieved number of layers in first Endcap part: " << layerDepths1.size() << endmsg; + lLog << MSG::DEBUG << "retrieved number of layers in second Endcap part: " << numSequencesR2 + << " , which end up to a full module depth in rho of " << moduleDepth2 << endmsg; + lLog << MSG::DEBUG << "retrieved number of layers in second Endcap part: " << layerDepths2.size() << endmsg; + lLog << MSG::DEBUG << "retrieved number of layers in third Endcap part: " << numSequencesR3 + << " , which end up to a full module depth in rho of " << moduleDepth3 << endmsg; + lLog << MSG::DEBUG << "retrieved number of layers in third Endcap part: " << layerDepths3.size() << endmsg; + + lLog << MSG::INFO << "constructing first part EC: with offset " << extBarrelOffset1 << ": "<< numSequencesZ1 + << " rings in Z, " << numSequencesR1 << " layers in Rho, " << numSequencesR1 * numSequencesZ1 + << " tiles" << endmsg; + + lLog << MSG::INFO << "constructing second part EC: with offset " << extBarrelOffset2 << ": " << numSequencesZ2 + << " rings in Z, " << numSequencesR2 << " layers in Rho, " + << layerDepths2.size() * numSequencesZ2 << " tiles" << endmsg; + + lLog << MSG::INFO << "constructing third part EC: with offset " << extBarrelOffset3 << ": " << numSequencesZ3 + << " rings in Z, " << numSequencesR3 << " layers in Rho, " + << layerDepths3.size() * numSequencesZ3 << " tiles" << endmsg; + + lLog << MSG::INFO << "number of channels: " + << (numSequencesR1 * numSequencesZ1) + (numSequencesR2 * numSequencesZ2) + (numSequencesR3 * numSequencesZ3) + << endmsg; + + // Calculate correction along z based on the module size (can only have natural number of modules) + double dzDetector1 = (numSequencesZ1 * dzSequence) / 2 + 2 * dZEndPlate + space; + lLog << MSG::INFO + << "correction of dz (negative = size reduced) first part EC :" << dzDetector1*2 - dimensions.width()*2 + << endmsg; + double dzDetector2 = (numSequencesZ2 * dzSequence) / 2; + 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; + + double dzDetector3 = (numSequencesZ3 * dzSequence) / 2 + 2 * dZEndPlate + space; + lLog << MSG::INFO << "dz third part EC:" << dzDetector2 * 2 + << endmsg; + + // Add structural support made of steel inside of HCal + DetElement facePlate1(aHCal, "FacePlate_" + std::to_string(1 * sign), 0); + dd4hep::Tube facePlateShape1(dimensions.rmin1(), (sensitiveBarrel1Rmin - space), + (dzDetector1 - 2 * dZEndPlate - space)); + Volume facePlateVol1("facePlateVol1", facePlateShape1, aLcdd.material(xFacePlate.materialStr())); + facePlateVol1.setVisAttributes(aLcdd, xFacePlate.visStr()); + dd4hep::Position offsetFace1(0, 0, sign * extBarrelOffset1); + + // Faceplate for 2nd part of extended Barrel + DetElement facePlate2(aHCal, "FacePlate_" + std::to_string(2 * sign), 0); + dd4hep::Tube facePlateShape2(dimensions.rmin2(), (sensitiveBarrel2Rmin - space), + dzDetector2); + Volume facePlateVol2("facePlateVol2", facePlateShape2, aLcdd.material(xFacePlate.materialStr())); + facePlateVol2.setVisAttributes(aLcdd, xFacePlate.visStr()); + dd4hep::Position offsetFace2(0, 0, sign * extBarrelOffset2); + + // Faceplate for 3rd part of extended Barrel + DetElement facePlate3(aHCal, "FacePlate_" + std::to_string(3 * sign), 0); + dd4hep::Tube facePlateShape3(dimensions.rmin(), (sensitiveBarrel3Rmin - space), + (dzDetector3 - 2 * dZEndPlate - space)); + Volume facePlateVol3("facePlateVol3", facePlateShape3, aLcdd.material(xFacePlate.materialStr())); + facePlateVol3.setVisAttributes(aLcdd, xFacePlate.visStr()); + dd4hep::Position offsetFace3(0, 0, sign * extBarrelOffset3); + + PlacedVolume placedFacePlate1 = aEnvelope.placeVolume(facePlateVol1, offsetFace1); + facePlate1.setPlacement(placedFacePlate1); + PlacedVolume placedFacePlate2 = aEnvelope.placeVolume(facePlateVol2, offsetFace2); + facePlate2.setPlacement(placedFacePlate2); + PlacedVolume placedFacePlate3 = aEnvelope.placeVolume(facePlateVol3, offsetFace3); + facePlate3.setPlacement(placedFacePlate3); + + // Add structural support made of steel at both ends of extHCal + dd4hep::Tube endPlateShape1(dimensions.rmin1(), (dimensions.rmax1() - dSteelSupport), dZEndPlate); + Volume endPlateVol1("endPlateVol1", endPlateShape1, aLcdd.material(xEndPlate.materialStr())); + endPlateVol1.setVisAttributes(aLcdd, xEndPlate.visStr()); + dd4hep::Tube endPlateShape3(dimensions.rmin(), (dimensions.rmax() - dSteelSupport), dZEndPlate); + Volume endPlateVol3("endPlateVol3", endPlateShape3, aLcdd.material(xEndPlate.materialStr())); + endPlateVol3.setVisAttributes(aLcdd, xEndPlate.visStr()); + + // Endplates placed for the extended Barrels in front and in the back to the central Barrel + DetElement endPlatePos(aHCal, "endPlate_" + std::to_string(1 * sign), 0); + dd4hep::Position posOffset(0, 0, sign * (extBarrelOffset3 + dzDetector3 - dZEndPlate)); + PlacedVolume placedEndPlatePos = aEnvelope.placeVolume(endPlateVol3, posOffset); + endPlatePos.setPlacement(placedEndPlatePos); + + DetElement endPlateNeg(aHCal, "endPlate_" + std::to_string(2 * sign), 0); + dd4hep::Position negOffset(0, 0, sign * (extBarrelOffset1 - dzDetector1 + dZEndPlate)); + PlacedVolume placedEndPlateNeg = aEnvelope.placeVolume(endPlateVol1, negOffset); + endPlateNeg.setPlacement(placedEndPlateNeg); + + std::vector layers; + layers.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); + std::vector > seqInLayers; + seqInLayers.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); + std::vector tilesPerLayer; + tilesPerLayer.reserve(layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); + + // loop over R ("layers") + double layerR = 0.; + for (unsigned int idxLayer = 0; idxLayer < layerDepths1.size(); ++idxLayer) { + // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) + double rminLayer = sensitiveBarrel1Rmin + layerR; + double rmaxLayer = sensitiveBarrel1Rmin + layerR + layerDepths1.at(idxLayer); + layerR += layerDepths1.at(idxLayer); + + //alternate: even layers consist of tile sequence b, odd layer of tile sequence a + unsigned int sequenceIdx = (idxLayer+1) % 2; + + dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); + Volume tileSequenceVolume("HCalECTileSequenceVol1", tileSequenceShape, aLcdd.air()); + + lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; + + + dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector1 ); + Volume layerVolume("HCalECLayerVol1", layerShape, aLcdd.air()); + + + layerVolume.setVisAttributes(aLcdd.invisible()); + unsigned int idxSubMod = 0; + + dd4hep::Position moduleOffset1 (0,0,sign * extBarrelOffset1); + + dd4hep::PlacedVolume placedLayerVolume = aEnvelope.placeVolume(layerVolume, moduleOffset1); + unsigned int type1 = 0; + if (sign<0) { + type1 = 3; + } + placedLayerVolume.addPhysVolID("type", type1); // First module type=0,3 in front of second +/- + placedLayerVolume.addPhysVolID("layer", idxLayer); + layers.push_back(placedLayerVolume); - double tileZOffset = - 0.5* dzSequence; - - // first Z loop (tiles that make up a sequence) - for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; ++xCompColl, ++idxSubMod){ - xml_comp_t xComp = xCompColl; - dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); - - Volume tileVol("HCalECTileVol_"+ xComp.materialStr(), tileShape, lcdd.material(xComp.materialStr())); - tileVol.setVisAttributes(lcdd, xComp.visStr()); - - dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); - dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); - - if (xComp.isSensitive()){ - tileVol.setSensitiveDetector(sensDet); - tilesPerLayer.push_back(placedTileVol); - } - tileZOffset += xComp.thickness(); - } - - // second z loop (place sequences in layer) - std::vector seqs; - double zOffset = - dzDetector1 + 0.5 * dzSequence; //2*dZEndPlate + space + 0.5 * dzSequence; - - for (uint numSeq=0; numSeq < numSequencesZ1; numSeq++){ - dd4hep::Position tileSequencePosition(0, 0, zOffset); - dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); - placedTileSequenceVolume.addPhysVolID("row", numSeq); - seqs.push_back(placedTileSequenceVolume); - zOffset += dzSequence; - } - seqInLayers.push_back(seqs); - } // layers loop - - - layerR = 0.; - // Placement of subWedges in Wedge, 2nd part - for (unsigned int idxLayer = 0; idxLayer < layerDepths2.size(); ++idxLayer){ - // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) - double rminLayer = sensitiveBarrel2Rmin + layerR; - double rmaxLayer = sensitiveBarrel2Rmin + layerR + layerDepths2.at(idxLayer); - layerR += layerDepths2.at(idxLayer); - layerInnerRadii2.push_back(rminLayer); - - //alternate: even layers consist of tile sequence b, odd layer of tile sequence a - unsigned int sequenceIdx = (idxLayer+1) % 2; - - dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); - Volume tileSequenceVolume("HCalECTileSequenceVol2", tileSequenceShape, lcdd.air()); - - lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - - dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector2); - Volume layerVolume("HCalECLayerVol2", layerShape, lcdd.air()); - - layerVolume.setVisAttributes(lcdd.invisible()); - unsigned int idxSubMod = 0; - - double tileZOffset = - 0.5* dzSequence; - - // first Z loop (tiles that make up a sequence) - for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; ++xCompColl, ++idxSubMod){ - xml_comp_t xComp = xCompColl; - dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); - - Volume tileVol("HCalECTileVol_", tileShape, lcdd.material(xComp.materialStr())); - tileVol.setVisAttributes(lcdd, xComp.visStr()); - - dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); - dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); - - if (xComp.isSensitive()){ - tileVol.setSensitiveDetector(sensDet); - tilesPerLayer.push_back(placedTileVol); - } - tileZOffset += xComp.thickness(); - } // close first Z loop - - // second z loop (place sequences in layer) - std::vector seqs; - double zOffset = - dzDetector2 + 0.5 * dzSequence; //(dzSequence * 0.5); - - for (uint numSeq=0; numSeq < numSequencesZ2; numSeq++){ - dd4hep::Position tileSequencePosition(0, 0, zOffset); - dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); - placedTileSequenceVolume.addPhysVolID("row", numSeq); - seqs.push_back(placedTileSequenceVolume); - zOffset += dzSequence; - } - seqInLayers.push_back(seqs); - - dd4hep::Position moduleOffset2 (0, 0, sign * extBarrelOffset2); - dd4hep::PlacedVolume placedLayerVolume = envelopeVolume.placeVolume(layerVolume, moduleOffset2); - unsigned int type2 = 1; - if (sign<0){ - type2 = 4; - } - placedLayerVolume.addPhysVolID("type", type2); // Second module type=1,4 behind the first +/- - placedLayerVolume.addPhysVolID("layer", layerDepths1.size() + idxLayer); - layers.push_back(placedLayerVolume); - } - - layerR = 0.; - // Placement of subWedges in Wedge, 3th part - for (unsigned int idxLayer = 0; idxLayer < layerDepths3.size(); ++idxLayer){ - // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) - double rminLayer = sensitiveBarrel3Rmin + layerR; - double rmaxLayer = sensitiveBarrel3Rmin + layerR + layerDepths3.at(idxLayer); - layerR += layerDepths3.at(idxLayer); - layerInnerRadii3.push_back(rminLayer); - - - //alternate: even layers consist of tile sequence b, odd layer of tile sequence a - unsigned int sequenceIdx = (idxLayer+1) % 2; - - dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); - Volume tileSequenceVolume("HCalECTileSequenceVol3", tileSequenceShape, lcdd.air()); - - lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - - dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector3); - Volume layerVolume("HCalECLayerVol3", layerShape, lcdd.air()); - - layerVolume.setVisAttributes(lcdd.invisible()); - unsigned int idxSubMod = 0; - - double tileZOffset = - 0.5* dzSequence; - - // first Z loop (tiles that make up a sequence) - for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; ++xCompColl, ++idxSubMod){ - xml_comp_t xComp = xCompColl; - dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); - - Volume tileVol("HCalECTileVol_" , tileShape, lcdd.material(xComp.materialStr())); - tileVol.setVisAttributes(lcdd, xComp.visStr()); - - dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); - dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); - - if (xComp.isSensitive()){ - tileVol.setSensitiveDetector(sensDet); - tilesPerLayer.push_back(placedTileVol); - } - tileZOffset += xComp.thickness(); - } - - // second z loop (place sequences in layer) - std::vector seqs; - double zOffset = - dzDetector3 + 0.5 * dzSequence; //2*dZEndPlate + space + (dzSequence * 0.5); - - for (uint numSeq=0; numSeq < numSequencesZ3; numSeq++){ - dd4hep::Position tileSequencePosition(0, 0, zOffset); - dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); - placedTileSequenceVolume.addPhysVolID("row", numSeq); - seqs.push_back(placedTileSequenceVolume); - zOffset += dzSequence; - } - seqInLayers.push_back(seqs); - - dd4hep::Position moduleOffset3 (0, 0, sign * extBarrelOffset3); - dd4hep::PlacedVolume placedLayerVolume = envelopeVolume.placeVolume(layerVolume, moduleOffset3); - unsigned int type3 = 2; - if (sign<0){ - type3 = 5; - } - placedLayerVolume.addPhysVolID("type", type3); // Second module type=2,5 behind the first +/- - placedLayerVolume.addPhysVolID("layer", layerDepths1.size() + layerDepths2.size() + idxLayer); - layers.push_back(placedLayerVolume); - } // 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; - - // 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++){ - DetElement layerDet(caloDetElem, dd4hep::xml::_toString(sign*(iLayer+1), "layer%d"), sign*(iLayer+1)); - layerDet.setPlacement(layers[iLayer]); - - for (uint iSeq = 0; iSeq < seqInLayers[iLayer].size(); iSeq++){ - DetElement seqDet(layerDet, dd4hep::xml::_toString(iSeq, "seq%d"), sign*(iSeq+1)); - seqDet.setPlacement(seqInLayers[iLayer][iSeq]); - - DetElement tileDet(seqDet, dd4hep::xml::_toString(iSeq, "tile%d"), sign*(iSeq+1)); - tileDet.setPlacement(tilesPerLayer[iLayer]); - } - } - } // for signs loop - - // Place envelope volume - Volume motherVol = lcdd.pickMotherVolume(caloDetElem); - - PlacedVolume placedHCal = motherVol.placeVolume(envelopeVolume); - placedHCal.addPhysVolID("system", caloDetElem.id()); - caloDetElem.setPlacement(placedHCal); - - - // Create caloData object - auto caloData = new dd4hep::rec::LayeredCalorimeterData; - caloData->layoutType = dd4hep::rec::LayeredCalorimeterData::EndcapLayout; - caloDetElem.addExtension(caloData); - - caloData->extent[0] = sensitiveBarrel3Rmin; - caloData->extent[1] = sensitiveBarrel3Rmin + moduleDepth3; // - caloData->extent[2] = 0.; // NN: for barrel detectors this is 0 - caloData->extent[3] = dzDetector1 + dzDetector2 + dzDetector3; - - dd4hep::rec::LayeredCalorimeterData::Layer caloLayer; - - // IMPORTANT: the information below is used to calculate the cell position in CellPositionsHCalPhiThetaSegTool in k4RecCalorimeter - // if the definition distance or sensitive_thickness is modified, one also needs to modify CellPositionsHCalPhiThetaSegTool - for (unsigned int idxLayer = 0; idxLayer < layerDepths1.size(); ++idxLayer) { - const double difference_bet_r1r2 = layerDepths1.at(idxLayer); - caloLayer.distance = layerInnerRadii1.at(idxLayer); // radius of the current layer - caloLayer.sensitive_thickness = difference_bet_r1r2; // radial dimension of the current layer - caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; - caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; - - caloData->layers.push_back(caloLayer); + double tileZOffset = - 0.5* dzSequence; + + // first Z loop (tiles that make up a sequence) + for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; + ++xCompColl, ++idxSubMod) { + xml_comp_t xComp = xCompColl; + dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); + + Volume tileVol("HCalECTileVol_"+ xComp.materialStr() + , tileShape, + aLcdd.material(xComp.materialStr())); + tileVol.setVisAttributes(aLcdd, xComp.visStr()); + + dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); + dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); + + if (xComp.isSensitive()) { + tileVol.setSensitiveDetector(sensDet); + tilesPerLayer.push_back(placedTileVol); + } + tileZOffset += xComp.thickness(); + } + + // second z loop (place sequences in layer) + std::vector seqs; + double zOffset = - dzDetector1 + 0.5 * dzSequence; //2*dZEndPlate + space + 0.5 * dzSequence; + + for (uint numSeq=0; numSeq < numSequencesZ1; numSeq++){ + dd4hep::Position tileSequencePosition(0, 0, zOffset); + dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); + placedTileSequenceVolume.addPhysVolID("row", numSeq); + seqs.push_back(placedTileSequenceVolume); + zOffset += dzSequence; } + seqInLayers.push_back(seqs); + } + + + layerR = 0.; + // Placement of subWedges in Wedge, 2nd part + for (unsigned int idxLayer = 0; idxLayer < layerDepths2.size(); ++idxLayer) { + // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) + double rminLayer = sensitiveBarrel2Rmin + layerR; + double rmaxLayer = sensitiveBarrel2Rmin + layerR + layerDepths2.at(idxLayer); + layerR += layerDepths2.at(idxLayer); + + //alternate: even layers consist of tile sequence b, odd layer of tile sequence a + unsigned int sequenceIdx = (idxLayer+1) % 2; + + dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); + Volume tileSequenceVolume("HCalECTileSequenceVol2", tileSequenceShape, aLcdd.air()); + + lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; - for (unsigned int idxLayer = 0; idxLayer < layerDepths2.size(); ++idxLayer) { - const double difference_bet_r1r2 = layerDepths2.at(idxLayer); - caloLayer.distance = layerInnerRadii2.at(idxLayer); - caloLayer.sensitive_thickness = difference_bet_r1r2; - caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; - caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; - caloData->layers.push_back(caloLayer); + dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector2); + Volume layerVolume("HCalECLayerVol2", layerShape, aLcdd.air()); + + layerVolume.setVisAttributes(aLcdd.invisible()); + unsigned int idxSubMod = 0; + + double tileZOffset = - 0.5* dzSequence; + + // first Z loop (tiles that make up a sequence) + for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; + ++xCompColl, ++idxSubMod) { + xml_comp_t xComp = xCompColl; + dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); + + Volume tileVol("HCalECTileVol_" + , tileShape, + aLcdd.material(xComp.materialStr())); + tileVol.setVisAttributes(aLcdd, xComp.visStr()); + + dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); + dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); + + if (xComp.isSensitive()) { + tileVol.setSensitiveDetector(sensDet); + tilesPerLayer.push_back(placedTileVol); + } + tileZOffset += xComp.thickness(); } - for (unsigned int idxLayer = 0; idxLayer < layerDepths3.size(); ++idxLayer) { - const double difference_bet_r1r2 = layerDepths3.at(idxLayer); - caloLayer.distance = layerInnerRadii3.at(idxLayer); - caloLayer.sensitive_thickness = difference_bet_r1r2; - caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; - caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; + // second z loop (place sequences in layer) + std::vector seqs; + double zOffset = - dzDetector2 + 0.5 * dzSequence; //(dzSequence * 0.5); + + for (uint numSeq=0; numSeq < numSequencesZ2; numSeq++){ + dd4hep::Position tileSequencePosition(0, 0, zOffset); + dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); + placedTileSequenceVolume.addPhysVolID("row", numSeq); + seqs.push_back(placedTileSequenceVolume); + zOffset += dzSequence; + } + seqInLayers.push_back(seqs); - caloData->layers.push_back(caloLayer); + dd4hep::Position moduleOffset2 (0, 0, sign * extBarrelOffset2); + dd4hep::PlacedVolume placedLayerVolume = aEnvelope.placeVolume(layerVolume, moduleOffset2); + unsigned int type2 = 1; + if (sign<0) { + type2 = 4; } - return caloDetElem; -} -}// namespace det + placedLayerVolume.addPhysVolID("type", type2); // Second module type=1,4 behind the first +/- + placedLayerVolume.addPhysVolID("layer", layerDepths1.size() + idxLayer); + layers.push_back(placedLayerVolume); + } + + layerR = 0.; + // Placement of subWedges in Wedge, 3th part + for (unsigned int idxLayer = 0; idxLayer < layerDepths3.size(); ++idxLayer) { + // in Module rmin = 0 for first wedge, changed radius to the full radius starting at (0,0,0) + double rminLayer = sensitiveBarrel3Rmin + layerR; + double rmaxLayer = sensitiveBarrel3Rmin + layerR + layerDepths3.at(idxLayer); + layerR += layerDepths3.at(idxLayer); + + //alternate: even layers consist of tile sequence b, odd layer of tile sequence a + unsigned int sequenceIdx = (idxLayer+1) % 2; + + dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); + Volume tileSequenceVolume("HCalECTileSequenceVol3", tileSequenceShape, aLcdd.air()); + + lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; + + dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector3); + Volume layerVolume("HCalECLayerVol3", layerShape, aLcdd.air()); + + layerVolume.setVisAttributes(aLcdd.invisible()); + unsigned int idxSubMod = 0; + + double tileZOffset = - 0.5* dzSequence; + + // first Z loop (tiles that make up a sequence) + for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; + ++xCompColl, ++idxSubMod) { + xml_comp_t xComp = xCompColl; + dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); + + Volume tileVol("HCalECTileVol_" + , tileShape, + aLcdd.material(xComp.materialStr())); + tileVol.setVisAttributes(aLcdd, xComp.visStr()); + + dd4hep::Position tileOffset(0, 0, tileZOffset + 0.5 * xComp.thickness() ); + dd4hep::PlacedVolume placedTileVol = tileSequenceVolume.placeVolume(tileVol, tileOffset); + + if (xComp.isSensitive()) { + tileVol.setSensitiveDetector(sensDet); + tilesPerLayer.push_back(placedTileVol); + } + tileZOffset += xComp.thickness(); + } + + // second z loop (place sequences in layer) + std::vector seqs; + double zOffset = - dzDetector3 + 0.5 * dzSequence; //2*dZEndPlate + space + (dzSequence * 0.5); + + for (uint numSeq=0; numSeq < numSequencesZ3; numSeq++){ + dd4hep::Position tileSequencePosition(0, 0, zOffset); + dd4hep::PlacedVolume placedTileSequenceVolume = layerVolume.placeVolume(tileSequenceVolume, tileSequencePosition); + placedTileSequenceVolume.addPhysVolID("row", numSeq); + seqs.push_back(placedTileSequenceVolume); + zOffset += dzSequence; + } + seqInLayers.push_back(seqs); + + dd4hep::Position moduleOffset3 (0, 0, sign * extBarrelOffset3); + dd4hep::PlacedVolume placedLayerVolume = aEnvelope.placeVolume(layerVolume, moduleOffset3); + unsigned int type3 = 2; + if (sign<0) { + type3 = 5; + } + placedLayerVolume.addPhysVolID("type", type3); // Second module type=2,5 behind the first +/- + placedLayerVolume.addPhysVolID("layer", layerDepths1.size() + layerDepths2.size() + idxLayer); + layers.push_back(placedLayerVolume); + } + + // Placement of DetElements + lLog << MSG::DEBUG << "Layers in r : " << layers.size() << std::endl; + lLog << MSG::DEBUG << "Tiles in layers :" << tilesPerLayer.size() << std::endl; + + for (uint iLayer = 0; iLayer < (layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); iLayer++) { + DetElement layerDet(aHCal, dd4hep::xml::_toString(sign*(iLayer+1), "layer%d"), sign*(iLayer+1)); + layerDet.setPlacement(layers[iLayer]); + + for (uint iSeq = 0; iSeq < seqInLayers[iLayer].size(); iSeq++){ + DetElement seqDet(layerDet, dd4hep::xml::_toString(iSeq, "seq%d"), sign*(iSeq+1)); + seqDet.setPlacement(seqInLayers[iLayer][iSeq]); + + DetElement tileDet(seqDet, dd4hep::xml::_toString(iSeq, "tile%d"), sign*(iSeq+1)); + tileDet.setPlacement(tilesPerLayer[iLayer]); + } + } + +} + +static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4hep::SensitiveDetector sensDet) { + + + xml_det_t xmlDet = xmlElement; + std::string detName = xmlDet.nameStr(); + + // Make DetElement + dd4hep::DetElement hCalEC(detName, xmlDet.id()); + + // Make volume that envelopes the whole barrel; set material to air + Dimension dimensions(xmlDet.dimensions()); + + dd4hep::Tube envelope(dimensions.rmin(), dimensions.rmax1(), (dimensions.v_offset() + dimensions.z_length())); + dd4hep::Tube negative1(dimensions.rmin(), dimensions.rmax1(), (dimensions.offset() - dimensions.width())); + dd4hep::Tube negative2(dimensions.rmin(), dimensions.rmin1(), (dimensions.z_offset() - dimensions.dz())); + dd4hep::Tube negative3(dimensions.rmin(), dimensions.rmin2(), (dimensions.v_offset() - dimensions.z_length())); + dd4hep::SubtractionSolid envelopeShapeTmp1(envelope, negative1); + dd4hep::SubtractionSolid envelopeShapeTmp2(envelopeShapeTmp1, negative2); + dd4hep::SubtractionSolid envelopeShape(envelopeShapeTmp2, negative3); + + Volume envelopeVolume(detName + "_volume", envelopeShape, lcdd.air()); + envelopeVolume.setVisAttributes(lcdd, dimensions.visStr()); + + lLog << MSG::DEBUG << "Placing detector on the positive side: (cm) " << (dimensions.offset() + dimensions.dz()) + << endmsg; + buildEC(lcdd, sensDet, envelopeVolume, hCalEC, xmlElement, 1); + lLog << MSG::DEBUG << "Placing detector on the negative side: (cm) " << -(dimensions.offset() + dimensions.dz()) + << endmsg; + buildEC(lcdd, sensDet, envelopeVolume, hCalEC, xmlElement, -1); + + // Place envelope volume + Volume motherVol = lcdd.pickMotherVolume(hCalEC); + + PlacedVolume placedHCal = motherVol.placeVolume(envelopeVolume); + placedHCal.addPhysVolID("system", xmlDet.id()); + hCalEC.setPlacement(placedHCal); + + return hCalEC; +} +} // namespace hcal + DECLARE_DETELEMENT(CaloThreePartsEndcap_o1_v01, det::createHCalEC) diff --git a/detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp b/detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp index 30235a955..8ad039534 100644 --- a/detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp +++ b/detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp @@ -422,7 +422,6 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h 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++){ DetElement layerDet(caloDetElem, dd4hep::xml::_toString(sign*(iLayer+1), "layer%d"), sign*(iLayer+1)); From e66e3a429d0ca1000780797bbaad18240cc0a82f Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Thu, 8 Aug 2024 15:13:12 +0200 Subject: [PATCH 28/59] adding version nr also for the barrel xml --- .../compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml index cd012cdf4..c55d34dbd 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml @@ -52,6 +52,11 @@ system:4,layer:5,theta:9,phi:10 + + + + system:4,layer:5,row:9,theta:0,phi:10 + From 28374e4630bdb88edbfb5ab5223957197eb94793 Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Tue, 13 Aug 2024 13:50:41 +0200 Subject: [PATCH 29/59] update READMEs --- FCCee/ALLEGRO/compact/README.md | 2 +- detector/calorimeter/README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/FCCee/ALLEGRO/compact/README.md b/FCCee/ALLEGRO/compact/README.md index d5c7e70f0..92b21eae8 100644 --- a/FCCee/ALLEGRO/compact/README.md +++ b/FCCee/ALLEGRO/compact/README.md @@ -13,4 +13,4 @@ Added "turbine-style" endcap ecal, and invoke this in the top-level xml (replaci Added HCalBarrel_TileCal_v02.xml which uses HCalTileBarrel_o1_v02_geo.cpp and removed unused readout BarHCal_Readout_phi. Added HCalEndcaps_ThreeParts_TileCal_v02.xml which uses HCalThreePartsEndcap_o1_v02_geo.cpp. Additionally, wrt v02 the readout was migrated to the theta-phi segmentation; unused readout *Readout_phi was removed; radial dimensions of layers were modified, so the outer radius of all three cylinders is the same. -ALLEGRO_o1_v04: same as v03, but material in inner part of absorber in first layer of ECAL is configurable and set by default to G10 \ No newline at end of file +ALLEGRO_o1_v04: same as v03, but material in inner part of absorber in first layer of ECAL is configurable and set by default to G10 diff --git a/detector/calorimeter/README.md b/detector/calorimeter/README.md index 771b6acf6..b3958a351 100644 --- a/detector/calorimeter/README.md +++ b/detector/calorimeter/README.md @@ -37,6 +37,7 @@ This sub-detector makes calorimeter barrel. It is used in ALLEGRO detector conce ### o1_v01 Original version taken from [FCCDetectors](https://github.com/HEP-FCC/FCCDetectors/blob/70a989a6fc333610e3b1b979c3596da9c41543d8/Detector/DetFCChhHCalTile/src/HCalBarrel_geo.cpp). +In August 2024, added extension (LayeredCalorimeterData) to store radial layer radii and dimensions; made small updates of the code to improve readibility, while the functionality remains the same. ### o1_v02 Changes wrt o1_v01: Added extension (LayeredCalorimeterData) to store radial layer radii and dimensions. Added several checks for the geometry building and made small changes in the code to improve readibility. From a8fc6696d0b233863c9f6ac88ed3a12bc8b045fb Mon Sep 17 00:00:00 2001 From: michaela mlynarikova Date: Tue, 13 Aug 2024 23:31:28 +0200 Subject: [PATCH 30/59] add HCalTileBarrel_o1_v02_geo.cpp --- .../calorimeter/HCalTileBarrel_o1_v01_geo.cpp | 117 ++++++------------ detector/calorimeter/README.md | 4 +- 2 files changed, 43 insertions(+), 78 deletions(-) diff --git a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp index c6f359dd3..89be7154d 100644 --- a/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp +++ b/detector/calorimeter/HCalTileBarrel_o1_v01_geo.cpp @@ -1,7 +1,6 @@ // DD4hep #include "DD4hep/DetFactoryHelper.h" -#include using dd4hep::Volume; using dd4hep::DetElement; @@ -13,11 +12,11 @@ using dd4hep::PlacedVolume; #define endmsg std::endl #define lLog std::cout namespace MSG { -const std::string ERROR = "createHCalTileBarrel ERROR "; -const std::string DEBUG = "createHCalTileBarrel DEBUG "; -const std::string INFO = "createHCalTileBarrel INFO "; +const std::string DEBUG = " Debug: "; +const std::string INFO = " Info: "; } + namespace det { static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep::SensitiveDetector sensDet) { @@ -41,66 +40,55 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep xml_comp_t xSteelSupport = xmlDet.child(_Unicode(steel_support)); double dSteelSupport = xSteelSupport.thickness(); - lLog << MSG::DEBUG << "steel support thickness (cm): " << dSteelSupport / dd4hep::cm << endmsg; + lLog << MSG::DEBUG << "steel support thickness: " << dSteelSupport << " [cm]" << endmsg; lLog << MSG::DEBUG << "steel support material: " << xSteelSupport.materialStr() << endmsg; double sensitiveBarrelRmin = xDimensions.rmin() + xFacePlate.thickness() + space; // Hard-coded assumption that we have two different sequences for the modules std::vector sequences = {xmlDet.child(_Unicode(sequence_a)), xmlDet.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; - 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; - throw std::runtime_error("The dimensions of the sequence_a and sequence_b do not match."); - } - double dzSequence = dimensionsB.dz(); + // NOTE: This assumes that both have the same dimensions! + Dimension sequenceDimensions(sequences[1].dimensions()); + double dzSequence = sequenceDimensions.dz(); lLog << MSG::DEBUG << "sequence thickness " << dzSequence << endmsg; - // calculate the number of sequences fitting in Z + // calculate the number of modules fitting in Z unsigned int numSequencesZ = static_cast((2 * xDimensions.dz() - 2 * dZEndPlate - 2 * space) / dzSequence); + // get all 'layer' children of the 'layers' tag std::vector Layers; - for (xml_coll_t xCompColl(xmlDet.child(_Unicode(layers)), _Unicode(layer)); xCompColl; ++xCompColl) { - Layers.push_back(xCompColl); + for (xml_coll_t xCompColl(xmlDet.child(_Unicode(layers)), _Unicode(layer)); xCompColl; + ++xCompColl) { + Layers.push_back(xCompColl); } - unsigned int numLayersR = 0; + unsigned int numSequencesR = 0; double moduleDepth = 0.; std::vector layerDepths = std::vector(); - std::vector layerInnerRadii = std::vector(); for (std::vector::iterator it = Layers.begin(); it != Layers.end(); ++it) { xml_comp_t layer = *it; Dimension layerDimension(layer.dimensions()); - numLayersR += layerDimension.nModules(); + numSequencesR += layerDimension.nModules(); for (int nLayer = 0; nLayer < layerDimension.nModules(); nLayer++) { moduleDepth += layerDimension.dr(); layerDepths.push_back(layerDimension.dr()); } } - lLog << MSG::DEBUG << "retrieved number of radial layers: " << numLayersR - << " , which end up to a full module depth in rho of " << moduleDepth << " cm" << endmsg; - lLog << MSG::DEBUG << "retrieved number of radial layers: " << layerDepths.size() << endmsg; + lLog << MSG::DEBUG << "retrieved number of layers: " << numSequencesR + << " , which end up to a full module depth in rho of " << moduleDepth << endmsg; + lLog << MSG::DEBUG << "retrieved number of layers: " << layerDepths.size() << endmsg; - lLog << MSG::INFO << "constructing: " << numSequencesZ << " sequences in Z, " << numLayersR - << " radial layers, in total " << numLayersR * numSequencesZ << " tiles" << endmsg; + lLog << MSG::INFO << "constructing: " << numSequencesZ << " rings in Z, " << numSequencesR + << " layers in Rho, " << numSequencesR * numSequencesZ << " tiles" << endmsg; // Calculate correction along z based on the module size (can only have natural number of modules) double dzDetector = (numSequencesZ * dzSequence) / 2 + dZEndPlate + space; - lLog << MSG::DEBUG << "dzDetector (cm): " << dzDetector / dd4hep::cm << endmsg; - lLog << MSG::INFO << "correction of dz in cm (negative = size reduced):" << dzDetector - xDimensions.dz() << endmsg; + lLog << MSG::DEBUG << "dzDetector: " << dzDetector << endmsg; + lLog << MSG::INFO << "correction of dz (negative = size reduced):" << dzDetector - xDimensions.dz() << endmsg; double rminSupport = sensitiveBarrelRmin + moduleDepth; double rmaxSupport = sensitiveBarrelRmin + moduleDepth + dSteelSupport; - double sensitiveBarrelRmax = sensitiveBarrelRmin + moduleDepth; - ////////////////////// detector building ////////////////////// @@ -114,11 +102,10 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep // top level det element representing whole hcal barrel - DetElement caloDetElem(xmlDet.nameStr(), xmlDet.id()); + DetElement hCal(xmlDet.nameStr(), xmlDet.id()); /// envelope shape dd4hep::Tube envelopeShape(xDimensions.rmin(), xDimensions.rmax(), xDimensions.dz()); - Volume envelopeVolume("HCalEnvelopeVolume", envelopeShape, lcdd.air()); envelopeVolume.setVisAttributes(lcdd, xDimensions.visStr()); @@ -127,7 +114,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep Volume facePlateVol("HCalFacePlateVol", facePlateShape, lcdd.material(xFacePlate.materialStr())); facePlateVol.setVisAttributes(lcdd, xFacePlate.visStr()); PlacedVolume placedFacePlate = envelopeVolume.placeVolume(facePlateVol); - DetElement facePlate_det(caloDetElem, "HCalFacePlate", 0); + DetElement facePlate_det(hCal, "HCalFacePlate", 0); facePlate_det.setPlacement(placedFacePlate); // Add structural support made of steel at both ends of HCal @@ -135,21 +122,22 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep Volume endPlateVol("HCalEndPlateVol", endPlateShape, lcdd.material(xEndPlate.materialStr())); endPlateVol.setVisAttributes(lcdd, xEndPlate.visStr()); - DetElement endPlatePos(caloDetElem, "HCalEndPlatePos", 0); + DetElement endPlatePos(hCal, "HCalEndPlatePos", 0); dd4hep::Position posOffset(0, 0, dzDetector - (dZEndPlate / 2)); PlacedVolume placedEndPlatePos = envelopeVolume.placeVolume(endPlateVol, posOffset); endPlatePos.setPlacement(placedEndPlatePos); - DetElement endPlateNeg(caloDetElem, "HCalEndPlateNeg", 1); + DetElement endPlateNeg(hCal, "HCalEndPlateNeg", 1); dd4hep::Position negOffset(0, 0, -dzDetector + (dZEndPlate / 2)); PlacedVolume placedEndPlateNeg = envelopeVolume.placeVolume(endPlateVol, negOffset); endPlateNeg.setPlacement(placedEndPlateNeg); dd4hep::Tube supportShape(rminSupport, rmaxSupport, (dzDetector - dZEndPlate - space)); - Volume steelSupportVolume("HCalSteelSupportVol", supportShape, lcdd.material(xSteelSupport.materialStr())); + Volume steelSupportVolume("HCalSteelSupportVol", supportShape, + lcdd.material(xSteelSupport.materialStr())); steelSupportVolume.setVisAttributes(lcdd.invisible()); PlacedVolume placedSupport = envelopeVolume.placeVolume(steelSupportVolume); - DetElement support(caloDetElem, "HCalSteelSupport", 0); + DetElement support(hCal, "HCalSteelSupport", 0); support.setPlacement(placedSupport); // double sensitiveBarrelDz = dzDetector - dZEndPlate; @@ -163,13 +151,15 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep double rminLayer = sensitiveBarrelRmin + layerR; double rmaxLayer = sensitiveBarrelRmin + layerR + layerDepths.at(idxLayer); layerR += layerDepths.at(idxLayer); - layerInnerRadii.push_back(rminLayer); //alternate: even layers consist of tile sequence b, odd layer of tile sequence a unsigned int sequenceIdx = idxLayer % 2; dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence); - Volume tileSequenceVolume("HCalTileSequenceVol", tileSequenceShape, lcdd.air()); + Volume tileSequenceVolume("HCalTileSequenceVol", tileSequenceShape, lcdd.air()); + + lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg; + dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector - dZEndPlate - space ); Volume layerVolume("HCalLayerVol", layerShape, lcdd.air()); @@ -186,7 +176,7 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep double tileZOffset = - 0.5* dzSequence; // first Z loop (tiles that make up a sequence) for (xml_coll_t xCompColl(sequences[sequenceIdx], _Unicode(module_component)); xCompColl; - ++xCompColl, ++idxSubMod) { + ++xCompColl, ++idxSubMod) { xml_comp_t xComp = xCompColl; dd4hep::Tube tileShape(rminLayer, rmaxLayer, 0.5 * xComp.thickness()); @@ -219,8 +209,8 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep } // Place det elements wihtin each other to recover volume positions later via cellID - for (uint iLayer = 0; iLayer < numLayersR; iLayer++) { - DetElement layerDet(caloDetElem, dd4hep::xml::_toString(iLayer, "layer%d"), iLayer); + for (uint iLayer = 0; iLayer < numSequencesR; iLayer++) { + DetElement layerDet(hCal, dd4hep::xml::_toString(iLayer, "layer%d"), iLayer); layerDet.setPlacement(layers[iLayer]); for (uint iSeq = 0; iSeq < seqInLayers[iLayer].size(); iSeq++){ @@ -233,39 +223,12 @@ static dd4hep::Ref_t createHCal(dd4hep::Detector& lcdd, xml_det_t xmlDet, dd4hep } // Place envelope (or barrel) volume - Volume motherVol = lcdd.pickMotherVolume(caloDetElem); + Volume motherVol = lcdd.pickMotherVolume(hCal); motherVol.setVisAttributes(lcdd.invisible()); - PlacedVolume envelopePhysVol = motherVol.placeVolume(envelopeVolume); - envelopePhysVol.addPhysVolID("system", caloDetElem.id()); - caloDetElem.setPlacement(envelopePhysVol); - - - // Create caloData object - auto caloData = new dd4hep::rec::LayeredCalorimeterData; - caloData->layoutType = dd4hep::rec::LayeredCalorimeterData::BarrelLayout; - caloDetElem.addExtension(caloData); - - caloData->extent[0] = sensitiveBarrelRmin; - caloData->extent[1] = sensitiveBarrelRmax; - caloData->extent[2] = 0.; // NN: for barrel detectors this is 0 - caloData->extent[3] = dzDetector; - - dd4hep::rec::LayeredCalorimeterData::Layer caloLayer; - - for (unsigned int idxLayer = 0; idxLayer < layerDepths.size(); ++idxLayer) { - const double difference_bet_r1r2 = layerDepths.at(idxLayer); - - caloLayer.distance = layerInnerRadii.at(idxLayer); // radius of the current layer - caloLayer.sensitive_thickness = difference_bet_r1r2; // radial dimension of the current layer - caloLayer.inner_thickness = difference_bet_r1r2 / 2.0; - caloLayer.outer_thickness = difference_bet_r1r2 / 2.0; - - caloData->layers.push_back(caloLayer); - } - - - return caloDetElem; - + PlacedVolume placedHCal = motherVol.placeVolume(envelopeVolume); + placedHCal.addPhysVolID("system", hCal.id()); + hCal.setPlacement(placedHCal); + return hCal; } } // namespace hcal diff --git a/detector/calorimeter/README.md b/detector/calorimeter/README.md index b3958a351..f55823bf7 100644 --- a/detector/calorimeter/README.md +++ b/detector/calorimeter/README.md @@ -37,7 +37,9 @@ This sub-detector makes calorimeter barrel. It is used in ALLEGRO detector conce ### o1_v01 Original version taken from [FCCDetectors](https://github.com/HEP-FCC/FCCDetectors/blob/70a989a6fc333610e3b1b979c3596da9c41543d8/Detector/DetFCChhHCalTile/src/HCalBarrel_geo.cpp). -In August 2024, added extension (LayeredCalorimeterData) to store radial layer radii and dimensions; made small updates of the code to improve readibility, while the functionality remains the same. + +### o1_v02 +Changes wrt o1_v01: Added extension (LayeredCalorimeterData) to store radial layer radii and dimensions. Added several checks for the geometry building and made small changes in the code to improve readibility. ### o1_v02 Changes wrt o1_v01: Added extension (LayeredCalorimeterData) to store radial layer radii and dimensions. Added several checks for the geometry building and made small changes in the code to improve readibility. From 3ef2b5546858207e1881dde5e416eddc86ce953d Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Tue, 27 Aug 2024 16:20:07 +0200 Subject: [PATCH 31/59] CLD_o2_v07: start with new lumical to fix overlaps --- FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml b/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml index 54c8af2f4..37f6a984d 100644 --- a/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml +++ b/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml @@ -157,7 +157,6 @@ outer_r = "LumiCal_Shield_outer_radius" inner_z = "LumiCal_max_z - LumiCal_shield_dz_prime + LumiCal_shield_dz"/> - From b7d37b3758f087f35c51184c6e863e6b71928a50 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Tue, 27 Aug 2024 16:23:52 +0200 Subject: [PATCH 32/59] CLD_o2_v07: remove old lumical xml --- .../compact/CLD_o2_v07/LumiCal_o3_v02_04.xml | 188 ------------------ 1 file changed, 188 deletions(-) delete mode 100644 FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_04.xml diff --git a/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_04.xml b/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_04.xml deleted file mode 100644 index cbc708e20..000000000 --- a/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_04.xml +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - - - - - system:8,barrel:3,layer:8,slice:8,r:32:-16,phi:-16 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 46604583313569f55273e278a58454ca2775452b Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Fri, 4 Oct 2024 08:12:09 -0700 Subject: [PATCH 33/59] Updates for v2 of turbine geometry --- .../ECalEndcap_Turbine_o1_v02_geo.cpp | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp index 1ffd0d329..19ce06196 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp @@ -143,7 +143,6 @@ namespace det { std::string nUnitCellsStr = nUnitCellsCStr; nUnitCells = std::stoi(nUnitCellsStr); } - int nUnitCellsLeastCommonMultiple = genericBladeElem.attr(_Unicode(nUnitCellsLeastCommonMultiple)); dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "nUnitCells: %d", nUnitCells); @@ -298,7 +297,7 @@ namespace det { dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "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; + //nUnitCellsToDraw = 2; dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "Number of unit cells %d", nUnitCells); @@ -386,6 +385,8 @@ namespace det { riLayer = ri; iLayer = 0; + std::vector LArVol_pvs; + for (auto LArTotalLayerVol: LArTotalLayerVols) { float roLayer = riLayer+delrActive; @@ -395,13 +396,14 @@ namespace det { dd4hep::Position posLayer(0,0,(zminLayer-zminri+roLayer-ro)/2.); dd4hep::PlacedVolume LArVol_pv(activeVol.placeVolume(LArTotalLayerVol, posLayer)); - dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "LAr layer: %d", iLayer ); + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "LAr layer: %d layer in readout: %d", iLayer, iWheel*ECalEndcapNumCalibLayers+iLayer ); LArVol_pv.addPhysVolID("layer", iWheel*ECalEndcapNumCalibLayers+iLayer); - + LArVol_pvs.push_back(LArVol_pv); + riLayer = roLayer; iLayer++; } - + for (int iUnitCell = 0; iUnitCell < nUnitCellsToDraw; iUnitCell++) { int modIndex = iUnitCell-nUnitCellsToDraw/2; @@ -447,11 +449,11 @@ namespace det { // place passive volume in LAr bath dd4hep::PlacedVolume passivePhysVol = aEnvelope.placeVolume(passiveVol, comCell); - passivePhysVol.addPhysVolID("module", modIndex*nUnitCellsLeastCommonMultiple/nUnitCells); + passivePhysVol.addPhysVolID("module", modIndex); passivePhysVol.addPhysVolID("wheel", iWheel); passivePhysVol.addPhysVolID("type", 1); // 0 = active, 1 = passive, 2 = readout - dd4hep::DetElement passiveDetElem(bathDetElem, "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); - passiveDetElem.setPlacement(passivePhysVol); + // dd4hep::DetElement passiveDetElem(bathDetElem, "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); + dd4hep::DetElement passiveDetElem( "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); passiveDetElem.setPlacement(passivePhysVol); // place active volume in LAr bath @@ -460,13 +462,20 @@ namespace det { zCell = 0.; dd4hep::Transform3D comCell2(r3d2, dd4hep::Translation3D(xCell,yCell,zCell)); dd4hep::PlacedVolume activePhysVol = aEnvelope.placeVolume(activeVol, comCell2); - activePhysVol.addPhysVolID("module", modIndex*nUnitCellsLeastCommonMultiple/nUnitCells); + activePhysVol.addPhysVolID("module", modIndex); activePhysVol.addPhysVolID("wheel", iWheel); activePhysVol.addPhysVolID("type", 0); // 0 = active, 1 = passive, 2 = readout - dd4hep::DetElement activeDetElem(bathDetElem, "active_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); + dd4hep::DetElement activeDetElem(bathDetElem, "active" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), modIndex); + activeDetElem.setPlacement(activePhysVol); - + iLayer = 0; + for (auto LArVol_pv: LArVol_pvs) { + dd4hep::DetElement LArDetElem(activeDetElem,"layer"+std::to_string(modIndex)+"_"+std::to_string(iWheel)+"_"+std::to_string(iLayer), iLayer); + LArDetElem.setPlacement(LArVol_pv); + iLayer++; + } + riLayer = ri; iLayer =0; @@ -479,7 +488,7 @@ namespace det { } - void buildOneSide_Turbine(dd4hep::Detector& aLcdd, dd4hep::SensitiveDetector& aSensDet, + void buildOneSide_Turbine(dd4hep::Detector& aLcdd, dd4hep::DetElement& caloDetElem, dd4hep::SensitiveDetector& aSensDet, dd4hep::Volume& aEnvelope, dd4hep::xml::Handle_t& aXmlElement, unsigned& iModule) { @@ -492,8 +501,8 @@ namespace det { dd4hep::xml::DetElement xmlDetElem = aXmlElement; std::string nameDet = xmlDetElem.nameStr(); - dd4hep::DetElement caloDetElem(nameDet, xmlDetElem.id()); - + // dd4hep::DetElement caloDetElem(nameDet, xmlDetElem.id()); + dd4hep::xml::Dimension dim(aXmlElement.child(_Unicode(dimensions))); //build cryostat @@ -565,8 +574,13 @@ namespace det { std::string nobleLiquidMaterial = nobleLiquid.materialStr(); dd4hep::Volume bathVol(nobleLiquidMaterial + "_bath", bathOuterShape, aLcdd.material(nobleLiquidMaterial)); dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "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::PlacedVolume bathPhysVol = aEnvelope.placeVolume(bathVol); + dd4hep::DetElement bathDetElem(caloDetElem, "bath", 1); + bathDetElem.setPlacement(bathPhysVol); + // 3. Create detector structure double length = dim.dz() * 2.; double zOffsetEnvelope = -length / 2.; @@ -607,9 +621,6 @@ namespace det { } - dd4hep::PlacedVolume bathPhysVol = aEnvelope.placeVolume(bathVol); - bathDetElem.setPlacement(bathPhysVol); - dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "Total number of modules: %d", iModule); @@ -644,7 +655,7 @@ namespace det { dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "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); + buildOneSide_Turbine(aLcdd, caloDetElem, aSensDet, envelopeVol, aXmlElement, iModule); dd4hep::Assembly endcapsAssembly("ECalEndcaps_turbine"); @@ -653,8 +664,8 @@ namespace det { dd4hep::PlacedVolume envelopePositivePhysVol = endcapsAssembly.placeVolume(envelopeVol, envelopePositiveVolume_tr); envelopePositivePhysVol.addPhysVolID("side", 1); - dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0); - caloPositiveDetElem.setPlacement(envelopePositivePhysVol); + // dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0); + // caloPositiveDetElem.setPlacement(envelopePositivePhysVol); // make another placement for the negative z endcap dd4hep::Transform3D envelopeNegativeVolume_tr(dd4hep::RotationZYX( 0 ,0,180*dd4hep::deg), dd4hep::Translation3D(0, 0, -dim.z_offset())); @@ -662,8 +673,8 @@ namespace det { endcapsAssembly.placeVolume(envelopeVol, envelopeNegativeVolume_tr); envelopeNegativePhysVol.addPhysVolID("side", -1); - dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); - caloNegativeDetElem.setPlacement(envelopeNegativePhysVol); + // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); + //caloNegativeDetElem.setPlacement(envelopeNegativePhysVol); dd4hep::Volume motherVol = aLcdd.pickMotherVolume(caloDetElem); dd4hep::PlacedVolume envelopePhysVol = motherVol.placeVolume(endcapsAssembly); From ce076c7935e5e0d52c4e962390d41fac65fe7450 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Fri, 4 Oct 2024 08:12:20 -0700 Subject: [PATCH 34/59] Updates for v2 of turbine geometry --- .../src/FCCSWEndcapTurbine_k4geo.cpp | 135 +++++++++++------- 1 file changed, 87 insertions(+), 48 deletions(-) diff --git a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp index a3cf00b35..a5df08b71 100644 --- a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp +++ b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp @@ -11,9 +11,9 @@ namespace DDSegmentation { _description = "Turbine-specific segmentation in the global coordinates"; // register all necessary parameters - registerParameter("grid_size_rho", "Grid size in rho", m_gridSizeRho, std::vector()); - registerParameter("offset_rho", "Offset in rho", m_offsetRho, std::vector()); - registerIdentifier("identifier_rho", "Cell ID identifier for rho", m_rhoID, "rho"); // might want to have separate concepts for rho and layer... + // registerParameter("grid_size_rho", "Grid size in rho", m_gridSizeRho, std::vector()); + // registerParameter("offset_rho", "Offset in rho", m_offsetRho, std::vector()); + // registerIdentifier("identifier_rho", "Cell ID identifier for rho", m_rhoID, "rho"); // might want to have separate concepts for rho and layer... registerParameter("grid_size_z", "Grid size in z", m_gridSizeZ, 0.); registerParameter("offset_z", "Offset in z", m_offsetZ, 0.); registerParameter("offset_theta", "Angular offset in theta", m_offsetTheta, 0., SegmentationParameter::AngleUnit, true); @@ -25,37 +25,49 @@ namespace DDSegmentation { try { m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle1")); - std::cout << "Blade angle 1 is " << m_bladeAngle[0] << std::endl; } catch(...) { - std::cout << "Blade angle 1 not found in detector metadata, exiting..." << std::endl; + std::cout << "BladeAngle1 not found in detector metadata, exiting..." << std::endl; exit(1); } try { m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle2")); - std::cout << "Blade angle 2 is " << m_bladeAngle[1] << std::endl; } catch(...) { - std::cout << "Blade angle 2 not found in detector metadata, exiting..." << std::endl; + std::cout << "BladeAngle2 not found in detector metadata, exiting..." << std::endl; exit(1); } try { m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle3")); - std::cout << "Blade angle 3 is " << m_bladeAngle[2] << std::endl; } catch(...) { - std::cout << "Blade angle 3 not found in detector metadata, exiting..." << std::endl; + std::cout << "BladeAngle3 not found in detector metadata, exiting..." << std::endl; exit(1); } + m_nUnitCells.clear(); try { - m_nUnitCellsLeastCommonMultiple = dd4hepgeo->constant("nUnitCellsLeastCommonMultiple"); + m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells1")); } catch(...) { - std::cout << "nUnitCellsLeastCommonMultiple not found in detector metadata, exiting..." << std::endl; + std::cout << "nUnitCells1 not found in detector metadata, exiting..." << std::endl; exit(1); } - + try { + m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells2")); + } + catch(...) { + std::cout << "nUnitCells2 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + try { + m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells3")); + } + catch(...) { + std::cout << "nUnitCells3 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + } FCCSWEndcapTurbine_k4geo::FCCSWEndcapTurbine_k4geo(const BitFieldCoder* decoder) : Segmentation(decoder) { @@ -64,9 +76,9 @@ namespace DDSegmentation { _description = "Turbine-specific segmentation in the global coordinates"; // register all necessary parameters - registerParameter("grid_size_rho", "Grid size in rho", m_gridSizeRho, std::vector()); - registerParameter("offset_rho", "Offset in rho", m_offsetRho, std::vector()); - registerIdentifier("identifier_rho", "Cell ID identifier for rho", m_rhoID, "rho"); + // registerParameter("grid_size_rho", "Grid size in rho", m_gridSizeRho, std::vector()); + // registerParameter("offset_rho", "Offset in rho", m_offsetRho, std::vector()); + // registerIdentifier("identifier_rho", "Cell ID identifier for rho", m_rhoID, "rho"); registerParameter("grid_size_z", "Grid size in z", m_gridSizeZ, 0.); registerParameter("offset_z", "Offset in z", m_offsetZ, 0.); registerParameter("offset_theta", "Angular offset in theta", m_offsetTheta, 0., SegmentationParameter::AngleUnit, true); @@ -80,47 +92,66 @@ namespace DDSegmentation { try { m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle1")); - std::cout << "Blade angle 1 is " << m_bladeAngle[0] << std::endl; } catch(...) { - std::cout << "Blade angle 1 not found in detector metadata, exiting..." << std::endl; + std::cout << "BladeAngle1 not found in detector metadata, exiting..." << std::endl; exit(1); } try { m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle2")); - std::cout << "Blade angle 2 is " << m_bladeAngle[1] << std::endl; } catch(...) { - std::cout << "Blade angle 2 not found in detector metadata, exiting..." << std::endl; + std::cout << "BladeAngle2 not found in detector metadata, exiting..." << std::endl; exit(1); } try { m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle3")); - std::cout << "Blade angle 3 is " << m_bladeAngle[2] << std::endl; } catch(...) { - std::cout << "Blade angle 3 not found in detector metadata, exiting..." << std::endl; + std::cout << "BladeAngle3 not found in detector metadata, exiting..." << std::endl; exit(1); } + + + m_nUnitCells.clear(); try { - m_nUnitCellsLeastCommonMultiple = dd4hepgeo->constant("nUnitCellsLeastCommonMultiple"); + m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells1")); } catch(...) { - std::cout << "nUnitCellsLeastCommonMultiple not found in detector metadata, exiting..." << std::endl; + std::cout << "nUnitCells1 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + try { + m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells2")); + } + catch(...) { + std::cout << "nUnitCells2 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + try { + m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells3")); + } + catch(...) { + std::cout << "nUnitCells3 not found in detector metadata, exiting..." << std::endl; exit(1); } - } /// determine the local position based on the cell ID Vector3D FCCSWEndcapTurbine_k4geo::position(const CellID& cID) const { - double rhoVal = rho(cID); + // double rhoVal = rho(cID); // just the center of the blade double zVal = z(cID); double phiVal = phi(cID); - Vector3D pos = PositionRhoZPhi(rhoVal, zVal, phiVal); - // account for the fact that the -z endcap is mirrored wrt to the +z one - if (pos.Z < 0.) pos.Y = -pos.Y; + double xVal = x(cID); + + //Vector3D pos = PositionRhoZPhi(rhoVal, zVal, phiVal); + + // make a dummy "position" vector that has phi, x, and z + Vector3D pos(phiVal, xVal, zVal); + + // // account for the fact that the -z endcap is mirrored wrt to the +z one + // if (pos.Z < 0.) pos.Y = -pos.Y; return pos; } @@ -128,9 +159,9 @@ Vector3D FCCSWEndcapTurbine_k4geo::position(const CellID& cID) const { CellID FCCSWEndcapTurbine_k4geo::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const { CellID cID = vID; - double lRho = rhoFromXYZ(globalPosition); - CellID iWheel = _decoder->get(cID, m_wheelID); - _decoder->set(cID, m_rhoID, positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel])); + + // _decoder->set(cID, m_rhoID, positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel])); + //_decoder->set(cID, m_rhoID, 0); double lZ = TMath::Abs(globalPosition.Z); _decoder->set(cID, m_zID, positionToBin(lZ, m_gridSizeZ, m_offsetZ)); @@ -140,32 +171,40 @@ CellID FCCSWEndcapTurbine_k4geo::cellID(const Vector3D& /* localPosition */, con /// determine the azimuthal angle phi based on the cell ID double FCCSWEndcapTurbine_k4geo::phi(const CellID& cID) const { + // just return the phi of the module center CellID iModule = _decoder->get(cID, m_moduleID); CellID iWheel = _decoder->get(cID, m_wheelID); + CellID iSide = _decoder->get(cID, m_sideID); - double phiCent = twopi*(iModule+0.5)/m_nUnitCellsLeastCommonMultiple; + double phiCent = ((long long int)iSide)*twopi*(iModule)/m_nUnitCells[iWheel]; - double rhoLoc = rho(cID); - double zLoc = TMath::Abs(z(cID))-m_offsetZ - 45; // hard-code midpoint in z for now + return phiCent; + + //double rhoLoc = rho(cID); + //double zLoc = TMath::Abs(z(cID))-m_offsetZ - 45; // hard-code midpoint in z for now + + //double zCotBladeAngle = zLoc/TMath::Tan(m_bladeAngle[iWheel]); + // double x = zCotBladeAngle; + //double y = TMath::Sqrt(rhoLoc*rhoLoc - x*x); + //// rotate about z axis by phiCent + //double xprime = x*TMath::Cos(phiCent) +y*TMath::Sin(phiCent); + //double yprime = y*TMath::Cos(phiCent) -x*TMath::Sin(phiCent); + + //return TMath::ATan2(xprime,yprime); +} +/// determine the value of the x coordinate relative to the center of the blade + double FCCSWEndcapTurbine_k4geo::x(const CellID& cID) const { + CellID iWheel = _decoder->get(cID, m_wheelID); + double zLoc = TMath::Abs(z(cID))-m_offsetZ - 45; // hard-code midpoint in z for now - double zCotBladeAngle = zLoc/TMath::Tan(m_bladeAngle[iWheel]); + double zCotBladeAngle = zLoc/TMath::Tan(m_bladeAngle[iWheel]); + double x = zCotBladeAngle; - double x = zCotBladeAngle; - double y = TMath::Sqrt(rhoLoc*rhoLoc - x*x); - // rotate about z axis by phiCent - double xprime = x*TMath::Cos(phiCent) +y*TMath::Sin(phiCent); - double yprime = y*TMath::Cos(phiCent) -x*TMath::Sin(phiCent); - - return TMath::ATan2(xprime,yprime); + return x; } -/// determine the transverse distance from the beamline r based on the cell ID -double FCCSWEndcapTurbine_k4geo::rho(const CellID& cID) const { - CellID rhoValue = _decoder->get(cID, m_rhoID); - CellID iWheel = _decoder->get(cID, m_wheelID); - return binToPosition(rhoValue,m_gridSizeRho[iWheel], m_offsetRho[iWheel]); -} + /// determine local x in plane of blade based on the cell ID double FCCSWEndcapTurbine_k4geo::z(const CellID& cID) const { CellID zValue = _decoder->get(cID, m_zID); From 2be208fee6f73bf7793ac99aa8ade22d79f4545b Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Fri, 4 Oct 2024 08:12:30 -0700 Subject: [PATCH 35/59] Updates for v2 of turbine geometry --- .../FCCSWEndcapTurbine_k4geo.h | 40 ++++++------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h b/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h index 3b1d93bb6..e0a91b3e7 100644 --- a/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h +++ b/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h @@ -68,40 +68,24 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { * @param[in] aFieldName Field name for phi. */ inline void setFieldNamePhi(const std::string& fieldName) { m_phiID = fieldName; } - /** Determine the transverse distance from the beamline rho based on the cell ID. - * @param[in] aCellId ID of a cell. - * return rho. - */ - double rho(const CellID& aCellID) const; - /** Get the coordinate offset in rho. - * return The offset in rho. - */ - inline double offsetRho(int iWheel) const { return m_offsetRho[iWheel]; } - /** Get the field name for rho. - * return The field name for rho. - */ - inline const std::string& fieldNameRho() const { return m_rhoID; } - /** Set the number of bins in rho. - * @param[in] aNumberBins Number of bins in rho. - */ - inline void setRhoBins(int bins) { m_rhoBins = bins; } - /** Set the coordinate offset in rho. - * @param[in] aOffset Offset in rho. - */ - // inline void setOffsetRho(double offset) { m_offsetRho = offset; } - /** Set the field name used for transverse distance from IP rho. - * @param[in] aFieldName Field name for rho. - */ - inline void setFieldNameRho(const std::string& fieldName) { m_rhoID = fieldName; } /** Set the field name used for the wheel ID. * @param[in] aFieldName Field name for wheel. */ inline void setFieldNameWheel(const std::string& fieldName) {m_wheelID = fieldName; } + /** Determine the x coordinate based on the cell ID. + * @param[in] aCellId ID of a cell. + * return x. + */ + double x(const CellID& aCellID) const; /** Determine the z coordinate based on the cell ID. * @param[in] aCellId ID of a cell. * return z. */ double z(const CellID& aCellID) const; + /** Get the grid size in z for a given wheel + * return grid size in z + */ + inline double gridSizeZ() const { return m_gridSizeZ; } /** Get the coordinate offset in z. * return The offset in z. */ @@ -128,10 +112,10 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { } protected: - /// turbine blade angle + /// turbine blade angle in each wheel std::vector m_bladeAngle; - /// least common multiple of number of unit cells - int m_nUnitCellsLeastCommonMultiple; + /// number of unit cells in each wheel + std::vector m_nUnitCells; /// the number of bins in phi int m_phiBins; /// the coordinate offset in phi From 9afd33ef97f0353b5f3317c1ba95c5b79415b5d5 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Wed, 23 Oct 2024 15:38:32 -0700 Subject: [PATCH 36/59] Fix bugs in LAr bath placement and in placement of passive elements when split into layers --- .../ECalEndcap_Turbine_o1_v02_geo.cpp | 122 ++++++++++++------ 1 file changed, 84 insertions(+), 38 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp index 19ce06196..302eb1beb 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp @@ -93,16 +93,19 @@ namespace det { BladeAngle = genericBladeElem.attr(_Unicode(angle1)); AbsThickMin = absBladeElem.attr(_Unicode(thickness1)); BladeThicknessScaleFactor = absBladeElem.attr(_Unicode(thicknessScaleFactor1)); + nUnitCells = genericBladeElem.attr(_Unicode(nUnitCells1)); } if (iWheel == 1) { BladeAngle = genericBladeElem.attr(_Unicode(angle2)); AbsThickMin = absBladeElem.attr(_Unicode(thickness2)); BladeThicknessScaleFactor = absBladeElem.attr(_Unicode(thicknessScaleFactor2)); + nUnitCells = genericBladeElem.attr(_Unicode(nUnitCells2)); } if (iWheel == 2) { BladeAngle = genericBladeElem.attr(_Unicode(angle3)); AbsThickMin = absBladeElem.attr(_Unicode(thickness3)); BladeThicknessScaleFactor = absBladeElem.attr(_Unicode(thicknessScaleFactor3)); + nUnitCells = genericBladeElem.attr(_Unicode(nUnitCells3)); } dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "Making wheel with inner, outer radii %f, %f", ri, ro); @@ -130,6 +133,7 @@ namespace det { float ElectrodeThick = electrodeBladeElem.attr(_Unicode(thickness)); float LArgapi = nobleLiquidElem.attr(_Unicode(gap)); +<<<<<<< HEAD bool sameNUnitCells = genericBladeElem.attr(_Unicode(sameNUnitCells)); char* nUnitCellsStrArr = (char*)genericBladeElem.attr(_Unicode(nUnitCells)).c_str(); char* nUnitCellsCStr = strtok(nUnitCellsStrArr, " "); @@ -143,6 +147,8 @@ namespace det { std::string nUnitCellsStr = nUnitCellsCStr; nUnitCells = std::stoi(nUnitCellsStr); } +======= +>>>>>>> c85fb7c2 (Fix bugs in LAr bath placement and in placement of passive elements when split into layers) dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "nUnitCells: %d", nUnitCells); @@ -297,7 +303,7 @@ namespace det { dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "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; + // nUnitCellsToDraw = 1; dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "Number of unit cells %d", nUnitCells); @@ -306,43 +312,49 @@ namespace det { unsigned iLayer = 0; riLayer = ri; - + for (auto absBladeLayerVol: absBladeLayerVols) { float roLayer = riLayer+delrNonActive; - dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); + //dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); + dd4hep::Position posLayer(0,0,0); dd4hep::PlacedVolume absBladeVol_pv = glueLayerVols[iLayer].placeVolume(absBladeLayerVol, posLayer); - absBladeVol_pv.addPhysVolID("subtype", 0); // 0 = absorber, 1 = glue, 2 = cladding + absBladeVol_pv.addPhysVolID("subtype", 4); // 1 = absorber, 2 = glue, 3 = cladding dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Blade layer, rho is %d, %f, %f", iLayer, absBladeVol_pv.position().Rho(), roLayer/2.); absBladeVol_pv.addPhysVolID("layer", iWheel*numNonActiveLayers+iLayer); + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "AbsBalde volume %s", absBladeVol_pv.toString().c_str()); riLayer = roLayer; iLayer++; } + riLayer = ri; iLayer =0; - + for (auto glueLayerVol: glueLayerVols) { float roLayer = riLayer+delrNonActive; - dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); + // dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); + dd4hep::Position posLayer(0,0,0); dd4hep::PlacedVolume glueVol_pv = claddingLayerVols[iLayer].placeVolume(glueLayerVol, posLayer); - glueVol_pv.addPhysVolID("subtype", 1); // 0 = absorber, 1 = glue, 2 = cladding + glueVol_pv.addPhysVolID("subtype", 1); // 1 = absorber, 2 = glue, 3 = cladding glueVol_pv.addPhysVolID("layer", iWheel*numNonActiveLayers+iLayer); // dd4hep::DetElement glueDetElem(passiveDetElem, "glue_",ECalEndCapElementCounter++); // glueDetElem.setPlacement(glueVol_pv); - + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Glue volume %s", glueVol_pv.toString().c_str()); riLayer = roLayer; iLayer++; } - + + riLayer = ri; iLayer =0; @@ -357,9 +369,10 @@ namespace det { dd4hep::Position posLayer(0,0,(zminLayer-zminri+roLayer-ro)/2.); dd4hep::PlacedVolume claddingVol_pv = passiveVol.placeVolume(claddingLayerVol, posLayer); - claddingVol_pv.addPhysVolID("subtype", 2); // 0 = absorber, 1 = glue, 2 = cladding + claddingVol_pv.addPhysVolID("subtype", 2); // 1 = absorber, 2 = glue, 3 = cladding claddingVol_pv.addPhysVolID("layer", iWheel*numNonActiveLayers+iLayer); + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Cladding volume %s", claddingVol_pv.toString().c_str()); // dd4hep::DetElement claddingDetElem(passiveDetElem, "cladding_", ECalEndCapElementCounter++); // claddingDetElem.setPlacement(claddingVol_pv); @@ -377,7 +390,9 @@ namespace det { dd4hep::PlacedVolume electrodeBladeVol_pv = LArTotalLayerVols[iLayer].placeVolume(electrodeBladeLayerVol); electrodeBladeVol_pv.addPhysVolID("layer", iWheel*numNonActiveLayers+iLayer); - + electrodeBladeVol_pv.addPhysVolID("type", 2); // 0 = active, 1 = passive, 2 = readout + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Electrode volume %s", electrodeBladeVol_pv.toString().c_str()); riLayer = roLayer; iLayer++; } @@ -399,7 +414,8 @@ namespace det { dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "LAr layer: %d layer in readout: %d", iLayer, iWheel*ECalEndcapNumCalibLayers+iLayer ); LArVol_pv.addPhysVolID("layer", iWheel*ECalEndcapNumCalibLayers+iLayer); LArVol_pvs.push_back(LArVol_pv); - + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "LAr volume %s", LArVol_pv.toString().c_str()); riLayer = roLayer; iLayer++; } @@ -455,6 +471,8 @@ namespace det { // dd4hep::DetElement passiveDetElem(bathDetElem, "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); dd4hep::DetElement passiveDetElem( "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); passiveDetElem.setPlacement(passivePhysVol); + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Passive volume %s", passivePhysVol.toString().c_str()); + // place active volume in LAr bath xCell = ((ro+zminri)/2.)*TMath::Cos(phi+delPhi/2.); @@ -467,6 +485,8 @@ namespace det { activePhysVol.addPhysVolID("type", 0); // 0 = active, 1 = passive, 2 = readout dd4hep::DetElement activeDetElem(bathDetElem, "active" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), modIndex); + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Active volume %s", activePhysVol.toString().c_str()); activeDetElem.setPlacement(activePhysVol); iLayer = 0; @@ -509,29 +529,39 @@ namespace det { // Retrieve cryostat data dd4hep::xml::DetElement cryostat = calo.child(_Unicode(cryostat)); dd4hep::xml::Dimension cryoDim(cryostat.dimensions()); - double cryoThicknessFront = cryoDim.rmin2() - cryoDim.rmin1(); - + double cryoThicknessFront = aLcdd.constant("CryoEMECThicknessFront"); + double cryoThicknessBack = aLcdd.constant("CryoEMECThicknessBack"); + double bathThicknessFront = aLcdd.constant("BathThicknessFront"); + double bathThicknessBack = aLcdd.constant("BathThicknessBack"); + + // double cryoThicknessInner = aLcdd.constant("CryoEMECThicknessInner"); + // double cryoThicknessOuter = aLcdd.constant("CryoEMECThicknessOuter"); + dd4hep::xml::DetElement cryoFront = cryostat.child(_Unicode(front)); dd4hep::xml::DetElement cryoBack = cryostat.child(_Unicode(back)); - dd4hep::xml::DetElement cryoSide = cryostat.child(_Unicode(side)); + dd4hep::xml::DetElement cryoInner = cryostat.child(_Unicode(inner)); + dd4hep::xml::DetElement cryoOuter = cryostat.child(_Unicode(outer)); + bool cryoFrontSensitive = cryoFront.isSensitive(); bool cryoBackSensitive = cryoBack.isSensitive(); - bool cryoSideSensitive = cryoSide.isSensitive(); - - double bathRmin = caloDim.rmin(); // - margin for inclination - double bathRmax = caloDim.rmax(); // + margin for inclination - double bathDelZ = caloDim.dz(); + bool cryoInnerSensitive = cryoInner.isSensitive(); + bool cryoOuterSensitive = cryoOuter.isSensitive(); + + double bathRmin = cryoDim.rmin2(); // - margin for inclination + double bathRmax = cryoDim.rmax1(); // + margin for inclination + double bathDelZ = cryoDim.dz(); 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 + // dd4hep::Tube bathAndServicesOuterShape(cryoDim.rmin2(), cryoDim.rmax1(), caloDim.dz()); // make it 4 volumes + 5th for detector envelope dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "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); + dd4hep::Tube cryoFrontShape(cryoDim.rmin1(), cryoDim.rmax2(), cryoThicknessFront/2.); + dd4hep::Tube cryoBackShape(cryoDim.rmin2(), cryoDim.rmax2(), cryoThicknessBack/2.); + dd4hep::Tube cryoInnerShape(cryoDim.rmin1(), cryoDim.rmin2(), cryoDim.dz()); + dd4hep::Tube cryoOuterShape(cryoDim.rmax1(), cryoDim.rmax2(), cryoDim.dz()); + // dd4hep::SubtractionSolid cryoSideShape(cryoSideOuterShape, bathAndServicesOuterShape); dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "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_v02", "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_v02", "ECAL endcap cryostat: side: rmin (cm) = %f rmax (cm) = %f dz (cm) = %f", cryoDim.rmin2(), cryoDim.rmax1(), cryoDim.dz() - caloDim.dz()); @@ -539,10 +569,15 @@ namespace det { dd4hep::Volume cryoFrontVol(cryostat.nameStr()+"_front", cryoFrontShape, aLcdd.material(cryostat.materialStr())); dd4hep::Volume cryoBackVol(cryostat.nameStr()+"_back", cryoBackShape, aLcdd.material(cryostat.materialStr())); - dd4hep::Volume cryoSideVol(cryostat.nameStr()+"_side", cryoSideShape, aLcdd.material(cryostat.materialStr())); - dd4hep::PlacedVolume cryoFrontPhysVol = aEnvelope.placeVolume(cryoFrontVol); - dd4hep::PlacedVolume cryoBackPhysVol = aEnvelope.placeVolume(cryoBackVol); - dd4hep::PlacedVolume cryoSidePhysVol = aEnvelope.placeVolume(cryoSideVol); + dd4hep::Volume cryoInnerVol(cryostat.nameStr()+"_inner", cryoInnerShape, aLcdd.material(cryostat.materialStr())); + dd4hep::Volume cryoOuterVol(cryostat.nameStr()+"_outer", cryoOuterShape, aLcdd.material(cryostat.materialStr())); + + dd4hep::Position cryoFrontPos(0,0,-cryoDim.dz()); + dd4hep::PlacedVolume cryoFrontPhysVol = aEnvelope.placeVolume(cryoFrontVol, cryoFrontPos); + dd4hep::Position cryoBackPos(0,0,cryoDim.dz()); + dd4hep::PlacedVolume cryoBackPhysVol = aEnvelope.placeVolume(cryoBackVol, cryoBackPos); + dd4hep::PlacedVolume cryoInnerPhysVol = aEnvelope.placeVolume(cryoInnerVol); + dd4hep::PlacedVolume cryoOuterPhysVol = aEnvelope.placeVolume(cryoOuterVol); unsigned sidetype = 0x4; // probably not needed anymore... if (cryoFrontSensitive) { cryoFrontVol.setSensitiveDetector(aSensDet); @@ -556,18 +591,26 @@ namespace det { cryoBackPhysVol.addPhysVolID("type", sidetype+2); dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "Cryostat back volume set as sensitive" ); } - if (cryoSideSensitive) { - cryoSideVol.setSensitiveDetector(aSensDet); - cryoSidePhysVol.addPhysVolID("cryo", 1); - cryoSidePhysVol.addPhysVolID("type", sidetype+3); - dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "Cryostat side volume set as sensitive" ); + if (cryoInnerSensitive) { + cryoInnerVol.setSensitiveDetector(aSensDet); + cryoInnerPhysVol.addPhysVolID("cryo", 1); + cryoInnerPhysVol.addPhysVolID("type", sidetype+3); + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "Cryostat inner volume set as sensitive" ); } + if (cryoOuterSensitive) { + cryoOuterVol.setSensitiveDetector(aSensDet); + cryoOuterPhysVol.addPhysVolID("cryo", 1); + cryoOuterPhysVol.addPhysVolID("type", sidetype+4); + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "Cryostat outer volume set as sensitive" ); + } dd4hep::DetElement cryoFrontDetElem(caloDetElem, "cryo_front", 0); cryoFrontDetElem.setPlacement(cryoFrontPhysVol); dd4hep::DetElement cryoBackDetElem(caloDetElem, "cryo_back", 0); cryoBackDetElem.setPlacement(cryoBackPhysVol); - dd4hep::DetElement cryoSideDetElem(caloDetElem, "cryo_side", 0); - cryoSideDetElem.setPlacement(cryoSidePhysVol); + dd4hep::DetElement cryoInnerDetElem(caloDetElem, "cryo_inner", 0); + cryoInnerDetElem.setPlacement(cryoInnerPhysVol); + dd4hep::DetElement cryoOuterDetElem(caloDetElem, "cryo_outer", 0); + cryoOuterDetElem.setPlacement(cryoOuterPhysVol); } // 2. Create noble liquid bath @@ -575,7 +618,9 @@ namespace det { dd4hep::Volume bathVol(nobleLiquidMaterial + "_bath", bathOuterShape, aLcdd.material(nobleLiquidMaterial)); dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "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::PlacedVolume bathPhysVol = aEnvelope.placeVolume(bathVol); + dd4hep::Position bathPos(0,0,(cryoThicknessFront-cryoThicknessBack)/2.); + + dd4hep::PlacedVolume bathPhysVol = aEnvelope.placeVolume(bathVol, bathPos); dd4hep::DetElement bathDetElem(caloDetElem, "bath", 1); @@ -597,6 +642,7 @@ namespace det { float supportTubeThickness=supportTubeElem.thickness(); unsigned iSupportTube = 0; + for (unsigned iWheel = 0; iWheel < nWheels; iWheel++) { dd4hep::Tube supportTube(ro, ro+supportTubeThickness, bathDelZ ); @@ -613,7 +659,7 @@ namespace det { supportTubeDetElem.setPlacement(supportTube_pv); - buildWheel(aLcdd, aSensDet, bathVol, aXmlElement, bathDetElem, ri+supportTubeThickness, ro, bathDelZ*2, iWheel); + buildWheel(aLcdd, aSensDet, bathVol, aXmlElement, bathDetElem, ri+supportTubeThickness, ro, bathDelZ*2-bathThicknessFront-bathThicknessBack, iWheel); ri = ro; ro *= radiusRatio; if (ro > rmax) ro = rmax; From f06281b4f97a5e0f4d2402b46f7d0e003c5cd985 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 21 Nov 2024 12:42:25 -0700 Subject: [PATCH 37/59] Calibration layers in z as well as rho --- .../ECalEndcap_Turbine_o1_v03_geo.cpp | 794 ++++++++++++++++++ 1 file changed, 794 insertions(+) create mode 100644 detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp new file mode 100644 index 000000000..2e7f1e084 --- /dev/null +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp @@ -0,0 +1,794 @@ +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "TMatrixT.h" + +// todo: remove gaudi logging and properly capture output +#define endmsg std::endl +#define lLog std::cout +namespace MSG { + const std::string ERROR = " Error: "; + const std::string DEBUG = " Debug: "; + const std::string INFO = " Info: "; +} + +namespace det { + + namespace ECalEndcap_Turbine_o1_v03 { + unsigned ECalEndCapElementCounter = 0; + const unsigned nWheels = 3; + + unsigned ECalEndcapNumCalibRhoLayersArr[nWheels], ECalEndcapNumCalibZLayersArr[nWheels]; + + + double tForArcLength(double s, double bladeangle, double delZ, double r) { + + // some intermediate constants + double zpos = delZ/2.; + double zp = zpos/TMath::Tan(bladeangle); + double b = zp/(TMath::Sqrt(r*r-zp*zp)); + double c = (TMath::Tan(s/r) +b)/(1.-b*TMath::Tan(s/r)); + double d = c*c*r*r/(1+c*c); + return (TMath::Sqrt(d)-zp)*TMath::Sin(bladeangle); + + // try approximating the arclength as dx. Less accurate, but that + // approximation is used in calculating the LAr gap, so maybe this + // will make it more consistent? + //return s*TMath::Sin(bladeangle); + + } + + // return position of the inner edge of a blade + double getZmin(double r, double bladeangle, double delZ) { + // r: distance from the beamline + // bladeangle: angle of turbine blades wrt xy plane, in radians + // delZ: z extent of the blades + return TMath::Sqrt(r*r - ((delZ/2)/TMath::Tan(bladeangle))*((delZ/2)/TMath::Tan(bladeangle))); + } + + dd4hep::Solid buildOneBlade(double thickness_inner, + double thickness_outer, + double width, + double ro, double ri, + double bladeangle, + double delZ, + double zStart) + { + + dd4hep::Solid shapeBeforeSubtraction; + + // set max and min extent of the blade (along the z axis in the body frame) + double zmax = ro; + double zmin = getZmin(ri, bladeangle, delZ); + + dd4hep::Trd2 tmp1(thickness_inner/2., thickness_outer/2., width/2., width/2., (zmax-zmin)/2. ); + shapeBeforeSubtraction = tmp1; + + dd4hep::Tube allowedTube(ri, ro, delZ); + + return dd4hep::IntersectionSolid (shapeBeforeSubtraction, allowedTube, dd4hep::Transform3D(dd4hep::RotationZYX( 0, TMath::Pi()/2.-bladeangle, TMath::Pi()/2.),dd4hep::Position(0,-zStart, -(zmin+zmax)/2.))); + + } + + void buildWheel(dd4hep::Detector& aLcdd, + dd4hep::SensitiveDetector& aSensDet, + dd4hep::Volume& aEnvelope, + dd4hep::xml::Handle_t& aXmlElement, + dd4hep::DetElement& bathDetElem, + float ri, float ro, float delZ, + unsigned iWheel) { + + + dd4hep::xml::DetElement calorimeterElem = aXmlElement.child(_Unicode(calorimeter)); + dd4hep::xml::DetElement genericBladeElem = calorimeterElem.child(_Unicode(turbineBlade)); + dd4hep::xml::DetElement absBladeElem = genericBladeElem.child(_Unicode(absorberBlade)); + dd4hep::xml::DetElement claddingElem = genericBladeElem.child(_Unicode(cladding)); + dd4hep::xml::DetElement glueElem = genericBladeElem.child(_Unicode(glue)); + dd4hep::xml::DetElement electrodeBladeElem = genericBladeElem.child(_Unicode(electrodeBlade)); + dd4hep::xml::DetElement nobleLiquidElem = genericBladeElem.child(_Unicode(nobleLiquidGap)); + + float BladeAngle = 0.0, AbsThickMin = 0.0, BladeThicknessScaleFactor=0.0; + unsigned nUnitCells = 0; + // hardcode for three wheels + unsigned ECalEndcapNumCalibRhoLayers = ECalEndcapNumCalibRhoLayersArr[iWheel], ECalEndcapNumCalibZLayers=ECalEndcapNumCalibZLayersArr[iWheel]; + + unsigned LayerIndexBaseline = 0; + + if (iWheel == 0) { + BladeAngle = genericBladeElem.attr(_Unicode(angle1)); + AbsThickMin = absBladeElem.attr(_Unicode(thickness1)); + BladeThicknessScaleFactor = absBladeElem.attr(_Unicode(thicknessScaleFactor1)); + + nUnitCells = genericBladeElem.attr(_Unicode(nUnitCells1)); + } + if (iWheel == 1) { + BladeAngle = genericBladeElem.attr(_Unicode(angle2)); + AbsThickMin = absBladeElem.attr(_Unicode(thickness2)); + BladeThicknessScaleFactor = absBladeElem.attr(_Unicode(thicknessScaleFactor2)); + nUnitCells = genericBladeElem.attr(_Unicode(nUnitCells2)); + LayerIndexBaseline = ECalEndcapNumCalibRhoLayersArr[0]*ECalEndcapNumCalibZLayersArr[0]; + } + if (iWheel == 2) { + BladeAngle = genericBladeElem.attr(_Unicode(angle3)); + AbsThickMin = absBladeElem.attr(_Unicode(thickness3)); + BladeThicknessScaleFactor = absBladeElem.attr(_Unicode(thicknessScaleFactor3)); + nUnitCells = genericBladeElem.attr(_Unicode(nUnitCells3)); + LayerIndexBaseline = ECalEndcapNumCalibRhoLayersArr[0]*ECalEndcapNumCalibZLayersArr[0] + ECalEndcapNumCalibRhoLayersArr[1]*ECalEndcapNumCalibZLayersArr[1]; + } + + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "Making wheel with inner, outer radii %f, %f", ri, ro); + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "Blade angle is %f ", BladeAngle); + dd4hep::xml::Dimension dim(aXmlElement.child(_Unicode(dimensions))); + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "delZ is %f", delZ); + + if (TMath::Abs(TMath::Tan(BladeAngle)) < delZ/(2.*ri)) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "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; + } + + Float_t xRange = delZ/(TMath::Sin(BladeAngle)); + + double delrPhiNoGap; + + float GlueThick = glueElem.attr(_Unicode(thickness)); + float CladdingThick = claddingElem.attr(_Unicode(thickness)); + + AbsThickMin = AbsThickMin-(GlueThick+CladdingThick); + if (AbsThickMin < 0.) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Error: requested absorber thickness is negative after accounting for glue and cladding thickness"); + } + float ElectrodeThick = electrodeBladeElem.attr(_Unicode(thickness)); + float LArgapi = nobleLiquidElem.attr(_Unicode(gap)); + + + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "nUnitCells: %d", nUnitCells); + + float AbsThicki = AbsThickMin; + // make volumes for the noble liquid, electrode, and absorber blades + float AbsThicko; + AbsThicko = AbsThicki + BladeThicknessScaleFactor*((ro/ri)-1.)*AbsThicki; + + // Calculate gap thickness at inner layer + double circ = 2*TMath::Pi()*ri; + double x2 =(AbsThickMin+(GlueThick+CladdingThick)+ElectrodeThick)/TMath::Sin(BladeAngle); + double y2 = TMath::Sqrt(ri*ri-x2*x2); + double rPhi1 = ri*TMath::Pi()/2.; + double rPhi2 = ri*TMath::ATan(y2/x2); + delrPhiNoGap = TMath::Abs(rPhi1-rPhi2); + double leftoverS = (circ - nUnitCells*delrPhiNoGap); + double delrPhiGapOnly = leftoverS/(2*nUnitCells); + LArgapi = delrPhiGapOnly*TMath::Sin(BladeAngle); + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "LArGap at inner radius is %f", LArgapi); + + // now find gap at outer radius + circ = 2*TMath::Pi()*ro; + x2 = (AbsThicko+GlueThick+CladdingThick+ElectrodeThick)/TMath::Sin(BladeAngle); + y2 = TMath::Sqrt(ro*ro-x2*x2); + rPhi1 = ro*TMath::Pi()/2.; + rPhi2 = ro*TMath::ATan(y2/x2); + delrPhiNoGap = TMath::Abs(rPhi1-rPhi2); + leftoverS = (circ - nUnitCells*delrPhiNoGap); + delrPhiGapOnly = leftoverS/(2*nUnitCells); + float LArgapo = delrPhiGapOnly*TMath::Sin(BladeAngle); + // LArgapo *= 2.; + + dd4hep::Solid absBlade; + float riLayer = ri; + + std::vector claddingLayerVols; + std::vector glueLayerVols; + std::vector absBladeLayerVols; + std::vector LArTotalLayerVols; + std::vector electrodeBladeLayerVols; + + + dd4hep::Solid passiveShape = buildOneBlade(AbsThicki+GlueThick+CladdingThick, AbsThicko+GlueThick+CladdingThick, xRange, ro, ri, BladeAngle, delZ, 0 ); + dd4hep::Volume passiveVol("passive", passiveShape, aLcdd.material("Air")); + + dd4hep::Solid activeShape = buildOneBlade(ElectrodeThick+LArgapi*2, ElectrodeThick+LArgapo*2, xRange, ro, ri, BladeAngle, delZ, 0); + dd4hep::Volume activeVol("active", activeShape, aLcdd.material("Air")); + + unsigned numNonActiveRhoLayers = 1; + unsigned numNonActiveZLayers = 1; + + // check that either all non-active volumes are set to sensitive (for + // sampling fraction calculations) or none are (for normal running) + bool allNonActiveSensitive = ( claddingElem.isSensitive() && + glueElem.isSensitive() && + absBladeElem.isSensitive() && + electrodeBladeElem.isSensitive() ); + bool allNonActiveNotSensitive = ( !claddingElem.isSensitive() && + !glueElem.isSensitive() && + !absBladeElem.isSensitive() && + !electrodeBladeElem.isSensitive() ); + if (allNonActiveSensitive) { + numNonActiveRhoLayers = ECalEndcapNumCalibRhoLayers; + numNonActiveZLayers = ECalEndcapNumCalibZLayers; + } + else if (!allNonActiveNotSensitive) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Some non-active layers are sensitive and others are not -- this is likely a misconfiguration"); + } + + float delrNonActive = (ro-ri)/numNonActiveRhoLayers; + float delrActive = (ro-ri)/ECalEndcapNumCalibRhoLayers; + + float delzNonActive = delZ/numNonActiveZLayers; + float delzActive = delZ/ECalEndcapNumCalibZLayers; + + for (unsigned iRhoLayer = 0; iRhoLayer < numNonActiveRhoLayers; iRhoLayer++) { + float roLayer = riLayer + delrNonActive; + dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Making layer with inner, outer radii %f, %f", riLayer, roLayer); + + AbsThicko = AbsThicki + BladeThicknessScaleFactor*((roLayer/riLayer)-1.)*AbsThicki; + + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "Inner and outer absorber thicknesses %f, %f ", AbsThicki, AbsThicko); + + float zStart = -xRange/2. + xRange/(2.*numNonActiveZLayers); + + for (unsigned iZLayer = 0; iZLayer < numNonActiveZLayers; iZLayer++) { + + dd4hep::Solid claddingLayer = buildOneBlade(AbsThicki+GlueThick+CladdingThick, AbsThicko+GlueThick+CladdingThick, xRange/numNonActiveZLayers, roLayer, riLayer, BladeAngle, delZ, zStart ); + + dd4hep::Solid glueLayer = buildOneBlade(AbsThicki+GlueThick, AbsThicko+GlueThick, xRange/numNonActiveZLayers, roLayer, riLayer, BladeAngle, delZ, zStart ); + + // dd4hep::SubtractionSolid claddingLayer(absGlueCladdingLayer, absGlueLayer); + dd4hep::Solid absBladeLayer = buildOneBlade(AbsThicki, AbsThicko, xRange/numNonActiveZLayers, roLayer, riLayer, BladeAngle, delZ, zStart ); + + // dd4hep::SubtractionSolid glueLayer(absGlueLayer, absBladeLayer); + dd4hep::Volume claddingLayerVol("claddingLayer", claddingLayer, aLcdd.material(claddingElem.materialStr())); + if (claddingElem.isSensitive()) { + claddingLayerVol.setSensitiveDetector(aSensDet); + } + claddingLayerVols.push_back(claddingLayerVol); + + dd4hep::Volume glueLayerVol("glueLayer", glueLayer, aLcdd.material(glueElem.materialStr())); + if (glueElem.isSensitive()) { + glueLayerVol.setSensitiveDetector(aSensDet); + } + glueLayerVols.push_back(glueLayerVol); + + dd4hep::Volume absBladeLayerVol("absBladeLayer", absBladeLayer, aLcdd.material(absBladeElem.materialStr())); + if (absBladeElem.isSensitive()) { + absBladeLayerVol.setSensitiveDetector(aSensDet); + } + absBladeLayerVols.push_back(absBladeLayerVol); + + zStart+=xRange/numNonActiveZLayers; + } + riLayer = roLayer; + AbsThicki = AbsThicko; + + } + + + riLayer = ri; + + AbsThicki = AbsThickMin; + + + for (unsigned iRhoLayer = 0; iRhoLayer < ECalEndcapNumCalibRhoLayers; iRhoLayer++) { + + float roLayer = riLayer + delrActive; + + AbsThicko = AbsThicki + BladeThicknessScaleFactor*((roLayer/riLayer)-1.)*AbsThicki; + + // now find gap at outer layer + circ = 2*TMath::Pi()*roLayer; + x2 = (AbsThicko+GlueThick+CladdingThick+ElectrodeThick)/TMath::Sin(BladeAngle); + y2 = TMath::Sqrt(roLayer*roLayer-x2*x2); + rPhi1 = roLayer*TMath::Pi()/2.; + rPhi2 = roLayer*TMath::ATan(y2/x2); + delrPhiNoGap = TMath::Abs(rPhi1-rPhi2); + leftoverS = (circ - nUnitCells*delrPhiNoGap); + delrPhiGapOnly = leftoverS/(2*nUnitCells); + LArgapo = delrPhiGapOnly*TMath::Sin(BladeAngle); + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "Outer LAr gap is %f", LArgapo) ; + dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Inner and outer thicknesses of noble liquid volume %f, %f", ElectrodeThick+LArgapi*2, ElectrodeThick+LArgapo*2); + + float zStart = -xRange/2. + xRange/(2.*ECalEndcapNumCalibZLayers); + + for (unsigned iZLayer = 0; iZLayer < ECalEndcapNumCalibZLayers; iZLayer++) { + + dd4hep::Solid electrodeBladeAndGapLayer = buildOneBlade(ElectrodeThick+LArgapi*2, ElectrodeThick+LArgapo*2, xRange/ECalEndcapNumCalibZLayers, roLayer, riLayer, BladeAngle, delZ, zStart); + + dd4hep::Solid electrodeBladeLayer = buildOneBlade(ElectrodeThick, ElectrodeThick, xRange/ECalEndcapNumCalibZLayers, roLayer, riLayer, BladeAngle, delZ, zStart); + + dd4hep::Volume electrodeBladeLayerVol("electrodeBladeLayer", electrodeBladeLayer, aLcdd.material(electrodeBladeElem.materialStr())); + if (electrodeBladeElem.isSensitive()) { + electrodeBladeLayerVol.setSensitiveDetector(aSensDet); + } + electrodeBladeLayerVols.push_back(electrodeBladeLayerVol); + + // dd4hep::SubtractionSolid LArShapeTotalLayer(electrodeBladeAndGapLayer, electrodeBladeLayer); + dd4hep::Volume LArTotalLayerVol("LArTotalLayerVol", electrodeBladeAndGapLayer, aLcdd.material(nobleLiquidElem.materialStr())); + + if ( nobleLiquidElem.isSensitive() ) { + LArTotalLayerVol.setSensitiveDetector(aSensDet); + } + LArTotalLayerVols.push_back(LArTotalLayerVol); + + zStart += xRange/ECalEndcapNumCalibZLayers; + } + riLayer = roLayer; + LArgapi = LArgapo; + AbsThicki = AbsThicko; + + } + dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "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 = 1; + + dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Number of unit cells %d", nUnitCells); + + // place all components of the absorber blade inside passive volume + + unsigned iLayer = 0; + + riLayer = ri; + + double xOffset = -xRange/2 + xRange/(2*numNonActiveZLayers); + + for (auto absBladeLayerVol: absBladeLayerVols) { + + float roLayer = riLayer+delrNonActive; + + //dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); + dd4hep::Position posLayer(0,0,0); + xOffset += xRange/numNonActiveZLayers; + dd4hep::PlacedVolume absBladeVol_pv = glueLayerVols[iLayer].placeVolume(absBladeLayerVol, posLayer); + + absBladeVol_pv.addPhysVolID("subtype", 4); // 1 = absorber, 2 = glue, 3 = cladding + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Blade layer, rho is %d, %f, %f", iLayer, absBladeVol_pv.position().Rho(), roLayer/2.); + absBladeVol_pv.addPhysVolID("layer", LayerIndexBaseline+iLayer); + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "AbsBalde volume %s", absBladeVol_pv.toString().c_str()); + + + iLayer++; + if (iLayer % numNonActiveZLayers ==0) { + riLayer = roLayer; + xOffset = -xRange/2 + xRange/(2*numNonActiveZLayers); + } + } + + + riLayer = ri; + iLayer =0; + + xOffset = -xRange/2 + xRange/(2*numNonActiveZLayers); + + for (auto glueLayerVol: glueLayerVols) { + + float roLayer = riLayer+delrNonActive; + + // dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); + dd4hep::Position posLayer(0,xOffset/2.,0); + dd4hep::PlacedVolume glueVol_pv = claddingLayerVols[iLayer].placeVolume(glueLayerVol, posLayer); + xOffset += xRange/numNonActiveZLayers; + + glueVol_pv.addPhysVolID("subtype", 1); // 1 = absorber, 2 = glue, 3 = cladding + glueVol_pv.addPhysVolID("layer", LayerIndexBaseline+iLayer); + + // dd4hep::DetElement glueDetElem(passiveDetElem, "glue_",ECalEndCapElementCounter++); + // glueDetElem.setPlacement(glueVol_pv); + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Glue volume %s", glueVol_pv.toString().c_str()); + + iLayer++; + if (iLayer % numNonActiveZLayers ==0) { + riLayer = roLayer; + xOffset = -xRange/2 + xRange/(2*numNonActiveZLayers); + } + } + + + riLayer = ri; + iLayer =0; + + double zminri = getZmin(ri, BladeAngle, delZ); + + xOffset = -xRange/2 + xRange/(2*numNonActiveZLayers); + + for (auto claddingLayerVol: claddingLayerVols) { + + float roLayer = riLayer+delrNonActive; + + double zminLayer = getZmin(riLayer, BladeAngle, delZ); + + dd4hep::Position posLayer(0,xOffset/2.,(zminLayer-zminri+roLayer-ro)/2.); + xOffset += xRange/numNonActiveZLayers; + dd4hep::PlacedVolume claddingVol_pv = passiveVol.placeVolume(claddingLayerVol, posLayer); + + claddingVol_pv.addPhysVolID("subtype", 2); // 1 = absorber, 2 = glue, 3 = cladding + claddingVol_pv.addPhysVolID("layer", LayerIndexBaseline+iLayer); + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Cladding volume %s", claddingVol_pv.toString().c_str()); + // dd4hep::DetElement claddingDetElem(passiveDetElem, "cladding_", ECalEndCapElementCounter++); + // claddingDetElem.setPlacement(claddingVol_pv); + + iLayer++; + if (iLayer % numNonActiveZLayers ==0) { + riLayer = roLayer; + xOffset = -xRange/2 + xRange/(2*numNonActiveZLayers); + } + + } + + + riLayer = ri; + iLayer = 0; + + xOffset = -xRange/2 + xRange/(2*ECalEndcapNumCalibZLayers); + + for (auto electrodeBladeLayerVol: electrodeBladeLayerVols) { + + float roLayer = riLayer+delrActive; + dd4hep::Position posLayer(0,0,0); + + dd4hep::PlacedVolume electrodeBladeVol_pv = LArTotalLayerVols[iLayer].placeVolume(electrodeBladeLayerVol, posLayer); + xOffset += xRange/ECalEndcapNumCalibZLayers; + electrodeBladeVol_pv.addPhysVolID("layer", LayerIndexBaseline+iLayer); + electrodeBladeVol_pv.addPhysVolID("type", 2); // 0 = active, 1 = passive, 2 = readout + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Electrode volume %s", electrodeBladeVol_pv.toString().c_str()); + + iLayer++; + if (iLayer % ECalEndcapNumCalibZLayers ==0) { + riLayer = roLayer; + xOffset = -xRange/2 + xRange/(2*ECalEndcapNumCalibZLayers); + } + } + + riLayer = ri; + iLayer = 0; + + std::vector LArVol_pvs; + + xOffset = -xRange/2 + xRange/(2*ECalEndcapNumCalibZLayers); + + for (auto LArTotalLayerVol: LArTotalLayerVols) { + + float roLayer = riLayer+delrActive; + + double zminLayer = getZmin(riLayer, BladeAngle, delZ); + + dd4hep::Position posLayer(0,xOffset,(zminLayer-zminri+roLayer-ro)/2.); + + dd4hep::PlacedVolume LArVol_pv(activeVol.placeVolume(LArTotalLayerVol, posLayer)); + xOffset += xRange/ECalEndcapNumCalibZLayers; + + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "LAr layer: %d layer in readout: %d", iLayer, LayerIndexBaseline+iLayer ); + LArVol_pv.addPhysVolID("layer", LayerIndexBaseline+iLayer); + LArVol_pvs.push_back(LArVol_pv); + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "LAr volume %s", LArVol_pv.toString().c_str()); + + iLayer++; + if (iLayer % ECalEndcapNumCalibZLayers ==0) { + riLayer = roLayer; + xOffset = -xRange/2 + xRange/(2*ECalEndcapNumCalibZLayers); + } + + } + + for (int iUnitCell = 0; iUnitCell < nUnitCellsToDraw; iUnitCell++) { + + int modIndex = iUnitCell-nUnitCellsToDraw/2; + if (modIndex < 0) modIndex += nUnitCells; + float phi = (iUnitCell-nUnitCellsToDraw/2)*2*TMath::Pi()/nUnitCells; + float delPhi = 2*TMath::Pi()/nUnitCells; + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "Placing blade, ro, ri = %f %f", ro, ri); + + TGeoRotation tgr; + tgr.RotateZ(BladeAngle*180/TMath::Pi()); + tgr.RotateX(-phi*180/TMath::Pi()); + tgr.RotateY(90); + + const Double_t *rotMatPtr; + + rotMatPtr = tgr.GetRotationMatrix(); + TMatrixT rotMat(3,3, rotMatPtr); + dd4hep::Rotation3D r3d; + r3d.SetComponents(rotMat(0,0), rotMat(0,1), rotMat(0,2), + rotMat(1,0), rotMat(1,1), rotMat(1,2), + rotMat(2,0), rotMat(2,1), rotMat(2,2)); + + tgr.Clear(); + tgr.RotateZ(BladeAngle*180/TMath::Pi()); + tgr.RotateX(-(phi+delPhi/2.)*180/TMath::Pi()); + tgr.RotateY(90); + + rotMatPtr = tgr.GetRotationMatrix(); + TMatrixT rotMat2(3,3, rotMatPtr); + dd4hep::Rotation3D r3d2; + r3d2.SetComponents(rotMat2(0,0), rotMat2(0,1), rotMat2(0,2), + rotMat2(1,0), rotMat2(1,1), rotMat2(1,2), + rotMat2(2,0), rotMat2(2,1), rotMat2(2,2)); + + riLayer = ri; + + float xCell = ((ro+zminri)/2.)*TMath::Cos(phi); + float yCell = ((ro+zminri)/2.)*TMath::Sin(phi); //ri*TMath::Sin(phi)/6.; + float zCell = 0.; + + dd4hep::Transform3D comCell(r3d, dd4hep::Translation3D(xCell,yCell,zCell)); + + // place passive volume in LAr bath + dd4hep::PlacedVolume passivePhysVol = aEnvelope.placeVolume(passiveVol, comCell); + passivePhysVol.addPhysVolID("module", modIndex); + passivePhysVol.addPhysVolID("wheel", iWheel); + passivePhysVol.addPhysVolID("type", 1); // 0 = active, 1 = passive, 2 = readout + // dd4hep::DetElement passiveDetElem(bathDetElem, "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); + dd4hep::DetElement passiveDetElem( "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); passiveDetElem.setPlacement(passivePhysVol); + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Passive volume %s", passivePhysVol.toString().c_str()); + + // place active volume in LAr bath + + xCell = ((ro+zminri)/2.)*TMath::Cos(phi+delPhi/2.); + yCell = ((ro+zminri)/2.)*TMath::Sin(phi+delPhi/2.); //ri*TMath::Sin(phi)/6.; + zCell = 0.; + dd4hep::Transform3D comCell2(r3d2, dd4hep::Translation3D(xCell,yCell,zCell)); + dd4hep::PlacedVolume activePhysVol = aEnvelope.placeVolume(activeVol, comCell2); + activePhysVol.addPhysVolID("module", modIndex); + activePhysVol.addPhysVolID("wheel", iWheel); + activePhysVol.addPhysVolID("type", 0); // 0 = active, 1 = passive, 2 = readout + + dd4hep::DetElement activeDetElem(bathDetElem, "active" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), modIndex); + + dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Active volume %s", activePhysVol.toString().c_str()); + + activeDetElem.setPlacement(activePhysVol); + iLayer = 0; + for (auto LArVol_pv: LArVol_pvs) { + dd4hep::DetElement LArDetElem(activeDetElem,"layer"+std::to_string(modIndex)+"_"+std::to_string(iWheel)+"_"+std::to_string(iLayer), iLayer); + LArDetElem.setPlacement(LArVol_pv); + iLayer++; + } + + riLayer = ri; + iLayer =0; + + + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "LArTotalLayerVols.size = %d", LArTotalLayerVols.size()); + + } + + return; + + } + + void buildOneSide_Turbine(dd4hep::Detector& aLcdd, dd4hep::DetElement& caloDetElem, dd4hep::SensitiveDetector& aSensDet, + dd4hep::Volume& aEnvelope, dd4hep::xml::Handle_t& aXmlElement, + unsigned& iModule) { + + dd4hep::xml::DetElement calo = aXmlElement.child(_Unicode(calorimeter)); + dd4hep::xml::Dimension caloDim(calo.dimensions()); + + + dd4hep::xml::DetElement blade = calo.child(_Unicode(turbineBlade)); + dd4hep::xml::DetElement nobleLiquid = blade.child(_Unicode(nobleLiquidGap)); + + dd4hep::xml::DetElement xmlDetElem = aXmlElement; + std::string nameDet = xmlDetElem.nameStr(); + // dd4hep::DetElement caloDetElem(nameDet, xmlDetElem.id()); + + dd4hep::xml::Dimension dim(aXmlElement.child(_Unicode(dimensions))); + + //build cryostat + // Retrieve cryostat data + dd4hep::xml::DetElement cryostat = calo.child(_Unicode(cryostat)); + dd4hep::xml::Dimension cryoDim(cryostat.dimensions()); + double cryoThicknessFront = aLcdd.constant("CryoEMECThicknessFront"); + double cryoThicknessBack = aLcdd.constant("CryoEMECThicknessBack"); + double bathThicknessFront = aLcdd.constant("BathThicknessFront"); + double bathThicknessBack = aLcdd.constant("BathThicknessBack"); + + // double cryoThicknessInner = aLcdd.constant("CryoEMECThicknessInner"); + // double cryoThicknessOuter = aLcdd.constant("CryoEMECThicknessOuter"); + + dd4hep::xml::DetElement cryoFront = cryostat.child(_Unicode(front)); + dd4hep::xml::DetElement cryoBack = cryostat.child(_Unicode(back)); + dd4hep::xml::DetElement cryoInner = cryostat.child(_Unicode(inner)); + dd4hep::xml::DetElement cryoOuter = cryostat.child(_Unicode(outer)); + + bool cryoFrontSensitive = cryoFront.isSensitive(); + bool cryoBackSensitive = cryoBack.isSensitive(); + bool cryoInnerSensitive = cryoInner.isSensitive(); + bool cryoOuterSensitive = cryoOuter.isSensitive(); + + double bathRmin = cryoDim.rmin2(); // - margin for inclination + double bathRmax = cryoDim.rmax1(); // + margin for inclination + double bathDelZ = cryoDim.dz(); + 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 + + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Cryostat front thickness is %f", cryoDim.rmin2() ); + + if (cryoThicknessFront > 0) { + // 1. Create cryostat + dd4hep::Tube cryoFrontShape(cryoDim.rmin1(), cryoDim.rmax2(), cryoThicknessFront/2.); + dd4hep::Tube cryoBackShape(cryoDim.rmin2(), cryoDim.rmax2(), cryoThicknessBack/2.); + dd4hep::Tube cryoInnerShape(cryoDim.rmin1(), cryoDim.rmin2(), cryoDim.dz()); + dd4hep::Tube cryoOuterShape(cryoDim.rmax1(), cryoDim.rmax2(), cryoDim.dz()); + // dd4hep::SubtractionSolid cryoSideShape(cryoSideOuterShape, bathAndServicesOuterShape); + dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "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_v03", "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_v03", "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_v03", "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())); + dd4hep::Volume cryoInnerVol(cryostat.nameStr()+"_inner", cryoInnerShape, aLcdd.material(cryostat.materialStr())); + dd4hep::Volume cryoOuterVol(cryostat.nameStr()+"_outer", cryoOuterShape, aLcdd.material(cryostat.materialStr())); + + dd4hep::Position cryoFrontPos(0,0,-cryoDim.dz()); + dd4hep::PlacedVolume cryoFrontPhysVol = aEnvelope.placeVolume(cryoFrontVol, cryoFrontPos); + dd4hep::Position cryoBackPos(0,0,cryoDim.dz()); + dd4hep::PlacedVolume cryoBackPhysVol = aEnvelope.placeVolume(cryoBackVol, cryoBackPos); + dd4hep::PlacedVolume cryoInnerPhysVol = aEnvelope.placeVolume(cryoInnerVol); + dd4hep::PlacedVolume cryoOuterPhysVol = aEnvelope.placeVolume(cryoOuterVol); + unsigned sidetype = 0x4; // probably not needed anymore... + if (cryoFrontSensitive) { + cryoFrontVol.setSensitiveDetector(aSensDet); + cryoFrontPhysVol.addPhysVolID("cryo", 1); + cryoFrontPhysVol.addPhysVolID("type", sidetype+1); + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Cryostat front volume set as sensitive"); + } + if (cryoBackSensitive) { + cryoBackVol.setSensitiveDetector(aSensDet); + cryoBackPhysVol.addPhysVolID("cryo", 1); + cryoBackPhysVol.addPhysVolID("type", sidetype+2); + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Cryostat back volume set as sensitive" ); + } + if (cryoInnerSensitive) { + cryoInnerVol.setSensitiveDetector(aSensDet); + cryoInnerPhysVol.addPhysVolID("cryo", 1); + cryoInnerPhysVol.addPhysVolID("type", sidetype+3); + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Cryostat inner volume set as sensitive" ); + } + if (cryoOuterSensitive) { + cryoOuterVol.setSensitiveDetector(aSensDet); + cryoOuterPhysVol.addPhysVolID("cryo", 1); + cryoOuterPhysVol.addPhysVolID("type", sidetype+4); + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Cryostat outer volume set as sensitive" ); + } + dd4hep::DetElement cryoFrontDetElem(caloDetElem, "cryo_front", 0); + cryoFrontDetElem.setPlacement(cryoFrontPhysVol); + dd4hep::DetElement cryoBackDetElem(caloDetElem, "cryo_back", 0); + cryoBackDetElem.setPlacement(cryoBackPhysVol); + dd4hep::DetElement cryoInnerDetElem(caloDetElem, "cryo_inner", 0); + cryoInnerDetElem.setPlacement(cryoInnerPhysVol); + dd4hep::DetElement cryoOuterDetElem(caloDetElem, "cryo_outer", 0); + cryoOuterDetElem.setPlacement(cryoOuterPhysVol); + } + + // 2. Create noble liquid bath + std::string nobleLiquidMaterial = nobleLiquid.materialStr(); + dd4hep::Volume bathVol(nobleLiquidMaterial + "_bath", bathOuterShape, aLcdd.material(nobleLiquidMaterial)); + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "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::Position bathPos(0,0,(cryoThicknessFront-cryoThicknessBack)/2.); + + dd4hep::PlacedVolume bathPhysVol = aEnvelope.placeVolume(bathVol, bathPos); + + dd4hep::DetElement bathDetElem(caloDetElem, "bath", 1); + + bathDetElem.setPlacement(bathPhysVol); + + // 3. Create detector structure + double length = dim.dz() * 2.; + double zOffsetEnvelope = -length / 2.; + + dd4hep::xml::DetElement supportTubeElem = calo.child(_Unicode(supportTube)); + unsigned nWheelsXML = supportTubeElem.attr(_Unicode(nWheels)); + if (nWheelsXML != nWheels) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Number of wheels in XML (%d) does not match hard-coded number of wheels (%d) ", nWheelsXML, nWheels); + } + + dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Will build %d wheels", nWheels); + double rmin = bathRmin; + double rmax = bathRmax; + float radiusRatio = pow(rmax/rmin, 1./nWheels); + double ro = rmin*radiusRatio; + double ri = rmin; + + float supportTubeThickness=supportTubeElem.thickness(); + unsigned iSupportTube = 0; + + + for (unsigned iWheel = 0; iWheel < nWheels; iWheel++) { + + dd4hep::Tube supportTube(ro, ro+supportTubeThickness, bathDelZ ); + + dd4hep::Volume supportTubeVol("supportTube", supportTube, aLcdd.material(supportTubeElem.materialStr())); + if (supportTubeElem.isSensitive()) { + supportTubeVol.setSensitiveDetector(aSensDet); + } + dd4hep::PlacedVolume supportTube_pv = bathVol.placeVolume(supportTubeVol, dd4hep::Position(0,0,zOffsetEnvelope + dim.dz() )); + supportTube_pv.addPhysVolID("cryo", 1); + // supportTube_pv.addPhysVolID("side",sign); + supportTube_pv.addPhysVolID("wheel", iWheel); + dd4hep::DetElement supportTubeDetElem(bathDetElem, "supportTube_"+std::to_string(iWheel), 0); + supportTubeDetElem.setPlacement(supportTube_pv); + + + buildWheel(aLcdd, aSensDet, bathVol, aXmlElement, bathDetElem, ri+supportTubeThickness, ro, bathDelZ*2-bathThicknessFront-bathThicknessBack, iWheel); + ri = ro; + ro *= radiusRatio; + if (ro > rmax) ro = rmax; + iSupportTube++; + } + + + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "Total number of modules: %d", iModule); + + + return; + } + + + + static dd4hep::Ref_t + createECalEndcapTurbine(dd4hep::Detector& aLcdd, dd4hep::xml::Handle_t aXmlElement, dd4hep::SensitiveDetector aSensDet) { + + dd4hep::xml::DetElement xmlDetElem = aXmlElement; + std::string nameDet = xmlDetElem.nameStr(); + int idDet = xmlDetElem.id(); + dd4hep::xml::Dimension dim(xmlDetElem.dimensions()); + dd4hep::DetElement caloDetElem(nameDet, idDet); + dd4hep::xml::Dimension sdType = xmlDetElem.child(_U(sensitive)); + aSensDet.setType(sdType.typeStr()); + + ECalEndcapNumCalibRhoLayersArr[0] = aLcdd.constant("ECalEndcapNumCalibRhoLayersWheel1"); + ECalEndcapNumCalibRhoLayersArr[1] = aLcdd.constant("ECalEndcapNumCalibRhoLayersWheel2"); + ECalEndcapNumCalibRhoLayersArr[2] = aLcdd.constant("ECalEndcapNumCalibRhoLayersWheel3"); + ECalEndcapNumCalibZLayersArr[0] = aLcdd.constant("ECalEndcapNumCalibZLayersWheel1"); + ECalEndcapNumCalibZLayersArr[1] = aLcdd.constant("ECalEndcapNumCalibZLayersWheel2"); + ECalEndcapNumCalibZLayersArr[2] = aLcdd.constant("ECalEndcapNumCalibZLayersWheel3"); + + + // Create air envelope for one endcap (will be copied to make both endcaps) + dd4hep::Tube endcapShape( dim.rmin1(), dim.rmax1(), dim.dz()); + + dd4hep::Volume envelopeVol(nameDet + "_vol", endcapShape, aLcdd.material("Air")); + + + // dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0); + // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); + + dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "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, caloDetElem, aSensDet, envelopeVol, aXmlElement, iModule); + + dd4hep::Assembly endcapsAssembly("ECalEndcaps_turbine"); + + // Place the envelope + dd4hep::Transform3D envelopePositiveVolume_tr(dd4hep::RotationZYX( 0 ,0,0), dd4hep::Translation3D(0, 0, dim.z_offset())); + dd4hep::PlacedVolume envelopePositivePhysVol = endcapsAssembly.placeVolume(envelopeVol, envelopePositiveVolume_tr); + envelopePositivePhysVol.addPhysVolID("side", 1); + + // dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0); + // caloPositiveDetElem.setPlacement(envelopePositivePhysVol); + + // make another placement for the negative z endcap + dd4hep::Transform3D envelopeNegativeVolume_tr(dd4hep::RotationZYX( 0 ,0,180*dd4hep::deg), dd4hep::Translation3D(0, 0, -dim.z_offset())); + dd4hep::PlacedVolume envelopeNegativePhysVol = + endcapsAssembly.placeVolume(envelopeVol, envelopeNegativeVolume_tr); + envelopeNegativePhysVol.addPhysVolID("side", -1); + + // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); + //caloNegativeDetElem.setPlacement(envelopeNegativePhysVol); + + dd4hep::Volume motherVol = aLcdd.pickMotherVolume(caloDetElem); + dd4hep::PlacedVolume envelopePhysVol = motherVol.placeVolume(endcapsAssembly); + caloDetElem.setPlacement(envelopePhysVol); + envelopePhysVol.addPhysVolID("system", idDet); + return caloDetElem; + } + } +} // namespace det + +DECLARE_DETELEMENT(ECalEndcap_Turbine_o1_v03, det::ECalEndcap_Turbine_o1_v03::createECalEndcapTurbine) From 082828a8e93d89311a36c57cc28b925e32eced53 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 21 Nov 2024 12:42:50 -0700 Subject: [PATCH 38/59] Update to use z calibration layers --- detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp index a5df08b71..d2a8a8cd7 100644 --- a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp +++ b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp @@ -148,7 +148,7 @@ Vector3D FCCSWEndcapTurbine_k4geo::position(const CellID& cID) const { //Vector3D pos = PositionRhoZPhi(rhoVal, zVal, phiVal); // make a dummy "position" vector that has phi, x, and z - Vector3D pos(phiVal, xVal, zVal); + Vector3D pos(phiVal, 0., 0); // // account for the fact that the -z endcap is mirrored wrt to the +z one // if (pos.Z < 0.) pos.Y = -pos.Y; From ef3dfc2e3937648d8c24aa5893c08e218052ce93 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Mon, 23 Dec 2024 09:36:13 -0700 Subject: [PATCH 39/59] Add v03 of the turbine geometry --- detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp index 2e7f1e084..a28d64c0e 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp @@ -316,7 +316,7 @@ namespace det { dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "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 = 1; + //nUnitCellsToDraw = 5; dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Number of unit cells %d", nUnitCells); From 133986c5aae30038d0459b94826e05e5ef99a2ca Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Fri, 10 Jan 2025 09:32:07 -0700 Subject: [PATCH 40/59] Updates for topological clustering --- .../ECalEndcap_Turbine_o1_v03_geo.cpp | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp index a28d64c0e..2084512ce 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp @@ -74,7 +74,7 @@ namespace det { dd4hep::Volume& aEnvelope, dd4hep::xml::Handle_t& aXmlElement, dd4hep::DetElement& bathDetElem, - float ri, float ro, float delZ, + float ri, float ro, float delZ, float offsetZ, unsigned iWheel) { @@ -130,6 +130,7 @@ namespace det { double delrPhiNoGap; float GlueThick = glueElem.attr(_Unicode(thickness)); + float CladdingThick = claddingElem.attr(_Unicode(thickness)); AbsThickMin = AbsThickMin-(GlueThick+CladdingThick); @@ -510,7 +511,7 @@ namespace det { float xCell = ((ro+zminri)/2.)*TMath::Cos(phi); float yCell = ((ro+zminri)/2.)*TMath::Sin(phi); //ri*TMath::Sin(phi)/6.; - float zCell = 0.; + float zCell = offsetZ; dd4hep::Transform3D comCell(r3d, dd4hep::Translation3D(xCell,yCell,zCell)); @@ -528,7 +529,7 @@ namespace det { xCell = ((ro+zminri)/2.)*TMath::Cos(phi+delPhi/2.); yCell = ((ro+zminri)/2.)*TMath::Sin(phi+delPhi/2.); //ri*TMath::Sin(phi)/6.; - zCell = 0.; + zCell = offsetZ; dd4hep::Transform3D comCell2(r3d2, dd4hep::Translation3D(xCell,yCell,zCell)); dd4hep::PlacedVolume activePhysVol = aEnvelope.placeVolume(activeVol, comCell2); activePhysVol.addPhysVolID("module", modIndex); @@ -714,7 +715,7 @@ namespace det { supportTubeDetElem.setPlacement(supportTube_pv); - buildWheel(aLcdd, aSensDet, bathVol, aXmlElement, bathDetElem, ri+supportTubeThickness, ro, bathDelZ*2-bathThicknessFront-bathThicknessBack, iWheel); + buildWheel(aLcdd, aSensDet, bathVol, aXmlElement, bathDetElem, ri+supportTubeThickness, ro, bathDelZ*2-bathThicknessFront-bathThicknessBack, (bathThicknessFront-bathThicknessBack)/2., iWheel); ri = ro; ro *= radiusRatio; if (ro > rmax) ro = rmax; @@ -740,14 +741,38 @@ namespace det { dd4hep::DetElement caloDetElem(nameDet, idDet); dd4hep::xml::Dimension sdType = xmlDetElem.child(_U(sensitive)); aSensDet.setType(sdType.typeStr()); - + + unsigned numReadoutRhoLayers, numReadoutZLayers; ECalEndcapNumCalibRhoLayersArr[0] = aLcdd.constant("ECalEndcapNumCalibRhoLayersWheel1"); + numReadoutRhoLayers = aLcdd.constant("ECalEndcapNumReadoutRhoLayersWheel1"); + if ((numReadoutRhoLayers % ECalEndcapNumCalibRhoLayersArr[0]) != 0) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Number of readout layers must be a multiple of number of calibration layers"); + } ECalEndcapNumCalibRhoLayersArr[1] = aLcdd.constant("ECalEndcapNumCalibRhoLayersWheel2"); + numReadoutRhoLayers = aLcdd.constant("ECalEndcapNumReadoutRhoLayersWheel2"); + if ((numReadoutRhoLayers % ECalEndcapNumCalibRhoLayersArr[1]) != 0) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Number of readout layers must be a multiple of number of calibration layers"); + } ECalEndcapNumCalibRhoLayersArr[2] = aLcdd.constant("ECalEndcapNumCalibRhoLayersWheel3"); + numReadoutRhoLayers = aLcdd.constant("ECalEndcapNumReadoutRhoLayersWheel3"); + if ((numReadoutRhoLayers % ECalEndcapNumCalibRhoLayersArr[2]) != 0) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Number of readout layers must be a multiple of number of calibration layers"); + } ECalEndcapNumCalibZLayersArr[0] = aLcdd.constant("ECalEndcapNumCalibZLayersWheel1"); + numReadoutZLayers = aLcdd.constant("ECalEndcapNumReadoutZLayersWheel1"); + if ((numReadoutZLayers % ECalEndcapNumCalibZLayersArr[0]) != 0) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Number of readout layers must be a multiple of number of calibration layers"); + } ECalEndcapNumCalibZLayersArr[1] = aLcdd.constant("ECalEndcapNumCalibZLayersWheel2"); + numReadoutZLayers = aLcdd.constant("ECalEndcapNumReadoutZLayersWheel2"); + if ((numReadoutZLayers % ECalEndcapNumCalibZLayersArr[1]) != 0) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Number of readout layers must be a multiple of number of calibration layers"); + } ECalEndcapNumCalibZLayersArr[2] = aLcdd.constant("ECalEndcapNumCalibZLayersWheel3"); - + numReadoutZLayers = aLcdd.constant("ECalEndcapNumReadoutZLayersWheel3"); + if ((numReadoutZLayers % ECalEndcapNumCalibZLayersArr[2]) != 0) { + dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v03", "Number of readout layers must be a multiple of number of calibration layers"); + } // Create air envelope for one endcap (will be copied to make both endcaps) dd4hep::Tube endcapShape( dim.rmin1(), dim.rmax1(), dim.dz()); From d3cd55b5715829866a1f7ff681c8cf665b0bcc35 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Fri, 10 Jan 2025 09:32:23 -0700 Subject: [PATCH 41/59] Updates for topological clustering --- .../FCCSWEndcapTurbine_k4geo.h | 86 +++++++++++++++++-- 1 file changed, 77 insertions(+), 9 deletions(-) diff --git a/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h b/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h index e0a91b3e7..51e172675 100644 --- a/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h +++ b/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h @@ -20,7 +20,8 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { FCCSWEndcapTurbine_k4geo(const std::string& aCellEncoding); /// Default constructor used by derived classes passing an existing decoder FCCSWEndcapTurbine_k4geo(const BitFieldCoder* decoder); - + ///common setup that needs to be done for either of the above constructors + void commonSetup(); /// destructor virtual ~FCCSWEndcapTurbine_k4geo() = default; @@ -34,6 +35,37 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { */ virtual CellID cellID(const Vector3D& aLocalPosition, const Vector3D& aGlobalPosition, const VolumeID& aVolumeID) const; + + /** Determine the transverse distance from the beamline (rho) based on the cell ID. + * @param[in] aCellId ID of a cell. + * return rho. + */ + double rho(const CellID& aCellID) const; + /** Get the grid size in rho for a given wheel + * return grid size in rho + */ + inline double gridSizeRho(int iWheel) const { return m_gridSizeRho[iWheel]; } + /** Get the number of cells in rho for a given wheel + * @param[in] iWheel wheel index + * return number of cells in rho for the specified wheel + */ + inline int numCellsRho(int iWheel) const {return m_numReadoutRhoLayers[iWheel];} + + /** Get the number of calibration cells in rho for a given wheel + * @param[in] iWheel wheel index + * return number of calibration cells in rho for the specified wheel + */ + inline int numCellsRhoCalib(int iWheel) const {return m_numCalibRhoLayers[iWheel];} + + /** Get the coordinate offset in rho for a given wheel. + * return The offset in rho. + */ + inline double offsetRho(int iWheel) const { return m_offsetRho[iWheel]; } + /** Get the field name for rho. + * return The field name for rho. + */ + + inline const std::string& fieldNameRho() const { return m_rhoID; } /** Determine the azimuthal angle based on the cell ID. * @param[in] aCellId ID of a cell. * return Phi. @@ -85,11 +117,24 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { /** Get the grid size in z for a given wheel * return grid size in z */ - inline double gridSizeZ() const { return m_gridSizeZ; } + inline double gridSizeZ(int iWheel) const { return m_gridSizeZ[iWheel]; } /** Get the coordinate offset in z. * return The offset in z. */ - inline double offsetZ() const { return m_offsetZ; } + /** Get the number of cells in z for a given wheel + * @param[in] iWheel wheel index + * return number of cells in z for the specified wheel + */ + inline int numCellsZ(int iWheel) const {return m_numReadoutZLayers[iWheel];} + /** Get the number of calibration cells in z for a given wheel + * @param[in] iWheel wheel index + * return number of calibration cells in z for the specified wheel + */ + inline int numCellsZCalib(int iWheel) const {return m_numCalibZLayers[iWheel];} /** Get the offset in z for a given wheel + * @param[in] iWheel wheel index + * return offset in z for the specified wheel + */ + inline double offsetZ(int iWheel) const { return m_offsetZ[iWheel]; } /** Get the field name for z. * return The field name for z. */ @@ -98,10 +143,11 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { * @param[in] aNumberBins Number of bins in z. */ inline void setZBins(int bins) { m_zBins = bins; } - /** Set the coordinate offset in z. + /** Set the coordinate offset in z for the specified wheel. + * @param[in] iWheel wheel index * @param[in] aOffset Offset in z. */ - inline void setOffsetZ(double offset) { m_offsetZ = offset; } + inline void setOffsetZ(int iWheel, double offset) { m_offsetZ[iWheel] = offset; } /** Set the field name used for z. * @param[in] aFieldName Field name for z. */ @@ -111,11 +157,32 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { return vec.Perp(); } + /** return the number of unit cells in each wheel + * @param[in] iWheel wheel identifier + */ + inline int nModules(int iWheel) { + return m_nUnitCells[iWheel]; + } + /** return the expected value of the layer index + * @param[in] iWheel wheel identifier + * @param[in] iRho rho readout cell identifier + * @param[in] iZ z readout cell identifier + */ + unsigned expLayer(unsigned iWheel, unsigned iRho, unsigned iZ) const; + protected: /// turbine blade angle in each wheel std::vector m_bladeAngle; /// number of unit cells in each wheel std::vector m_nUnitCells; + /// the number of cells in rho for each wheel + std::vector m_numReadoutRhoLayers; + /// the number of cells in z for each wheel + std::vector m_numReadoutZLayers; + /// the number of calibration cells in rho for each wheel + std::vector m_numCalibRhoLayers; + /// the number of calibration cells in z for each wheel + std::vector m_numCalibZLayers; /// the number of bins in phi int m_phiBins; /// the coordinate offset in phi @@ -126,9 +193,9 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { /// the number of bins in rho int m_rhoBins; ////grid size in rho - std::vector m_gridSizeRho; + std::vector m_gridSizeRho; /// the coordinate offset in rho - std::vector m_offsetRho; + std::vector m_offsetRho; /// the field name used for rho std::string m_rhoID; /// the field name used for wheel @@ -138,12 +205,13 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { /// the number of bins in z int m_zBins; ///grid size in z - double m_gridSizeZ; + std::vector m_gridSizeZ; /// the coordinate offset in z - double m_offsetZ; + std::vector m_offsetZ; /// the field name used for z std::string m_zID; std::string m_sideID; + std::string m_layerID; }; } } From a5c2e18e2a6b8d52cfc5828ad569892d45b8058d Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Fri, 10 Jan 2025 09:32:33 -0700 Subject: [PATCH 42/59] Updates for topological clustering --- .../src/FCCSWEndcapTurbine_k4geo.cpp | 243 ++++++++++++------ 1 file changed, 161 insertions(+), 82 deletions(-) diff --git a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp index d2a8a8cd7..da8da0c4d 100644 --- a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp +++ b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp @@ -6,21 +6,53 @@ namespace DDSegmentation { /// default constructor using an encoding string FCCSWEndcapTurbine_k4geo::FCCSWEndcapTurbine_k4geo(const std::string& cellEncoding) : Segmentation(cellEncoding) { + + commonSetup(); +} + + FCCSWEndcapTurbine_k4geo::FCCSWEndcapTurbine_k4geo(const BitFieldCoder* decoder) : Segmentation(decoder) { // define type and description + + commonSetup(); + +} + +/// initialize variables, etc (needed for either version of the ctor) +void FCCSWEndcapTurbine_k4geo::commonSetup() { _type = "FCCSWEndcapTurbine_k4geo"; _description = "Turbine-specific segmentation in the global coordinates"; // register all necessary parameters - // registerParameter("grid_size_rho", "Grid size in rho", m_gridSizeRho, std::vector()); - // registerParameter("offset_rho", "Offset in rho", m_offsetRho, std::vector()); - // registerIdentifier("identifier_rho", "Cell ID identifier for rho", m_rhoID, "rho"); // might want to have separate concepts for rho and layer... - registerParameter("grid_size_z", "Grid size in z", m_gridSizeZ, 0.); - registerParameter("offset_z", "Offset in z", m_offsetZ, 0.); + m_offsetRho.resize(3); + m_gridSizeRho.resize(3); + m_gridSizeZ.resize(3); + m_offsetZ.resize(3); + + registerParameter("offset_rho1", "Offset in rho1", m_offsetRho[0], 0.); + registerParameter("offset_rho2", "Offset in rho2", m_offsetRho[1], 0.); + registerParameter("offset_rho3", "Offset in rho3", m_offsetRho[2], 0.); + + registerIdentifier("identifier_rho", "Cell ID identifier for rho", m_rhoID, "rho"); + + registerParameter("grid_size_rho1", "Grid size in rho1", m_gridSizeRho[0], 0.); + registerParameter("grid_size_rho2", "Grid size in rho2", m_gridSizeRho[1], 0.); + registerParameter("grid_size_rho3", "Grid size in rho3", m_gridSizeRho[2], 0.); + + registerParameter("grid_size_z1", "Grid size in z1", m_gridSizeZ[0], 0.); + registerParameter("grid_size_z2", "Grid size in z2", m_gridSizeZ[1], 0.); + registerParameter("grid_size_z3", "Grid size in z3", m_gridSizeZ[2], 0.); + registerParameter("offset_z1", "Offset in z1", m_offsetZ[0], 0.); + registerParameter("offset_z2", "Offset in z2", m_offsetZ[1], 0.); + registerParameter("offset_z3", "Offset in z3", m_offsetZ[2], 0.); + registerParameter("offset_theta", "Angular offset in theta", m_offsetTheta, 0., SegmentationParameter::AngleUnit, true); registerIdentifier("identifier_z", "Cell ID identifier for z", m_zID, "z"); registerIdentifier("identifier_side", "Cell ID identifier for side", m_sideID, "side"); - + registerIdentifier("identifier_wheel", "Cell ID identifier for wheel", m_wheelID, "wheel"); + registerIdentifier("identifier_module", "Cell ID identifier for module", m_moduleID, "module"); + registerIdentifier("identifier_layer", "Cell ID identifier for layer", m_layerID, "layer"); dd4hep::Detector* dd4hepgeo = &(dd4hep::Detector::getInstance()); + m_bladeAngle.clear(); try { @@ -45,6 +77,7 @@ namespace DDSegmentation { exit(1); } + m_nUnitCells.clear(); try { m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells1")); @@ -67,91 +100,110 @@ namespace DDSegmentation { std::cout << "nUnitCells3 not found in detector metadata, exiting..." << std::endl; exit(1); } - -} - FCCSWEndcapTurbine_k4geo::FCCSWEndcapTurbine_k4geo(const BitFieldCoder* decoder) : Segmentation(decoder) { - // define type and description - _type = "FCCSWEndcapTurbine_k4geo"; - _description = "Turbine-specific segmentation in the global coordinates"; - - // register all necessary parameters - // registerParameter("grid_size_rho", "Grid size in rho", m_gridSizeRho, std::vector()); - // registerParameter("offset_rho", "Offset in rho", m_offsetRho, std::vector()); - // registerIdentifier("identifier_rho", "Cell ID identifier for rho", m_rhoID, "rho"); - registerParameter("grid_size_z", "Grid size in z", m_gridSizeZ, 0.); - registerParameter("offset_z", "Offset in z", m_offsetZ, 0.); - registerParameter("offset_theta", "Angular offset in theta", m_offsetTheta, 0., SegmentationParameter::AngleUnit, true); - registerIdentifier("identifier_z", "Cell ID identifier for z", m_zID, "z"); - registerIdentifier("identifier_side", "Cell ID identifier for side", m_sideID, "side"); - registerIdentifier("identifier_wheel", "Cell ID identifier for wheel", m_wheelID, "wheel"); - registerIdentifier("identifier_module", "Cell ID identifier for module", m_moduleID, "module"); - dd4hep::Detector* dd4hepgeo = &(dd4hep::Detector::getInstance()); + m_numReadoutRhoLayers.clear(); + try { + m_numReadoutRhoLayers.push_back(dd4hepgeo->constant("ECalEndcapNumReadoutRhoLayersWheel1")); + } + catch(...) { + std::cout << "ECalEndcapNumReadoutRhoLayersWheel1 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + try { + m_numReadoutRhoLayers.push_back(dd4hepgeo->constant("ECalEndcapNumReadoutRhoLayersWheel2")); + } + catch(...) { + std::cout << "ECalEndcapNumReadoutRhoLayersWheel2 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + try { + m_numReadoutRhoLayers.push_back(dd4hepgeo->constant("ECalEndcapNumReadoutRhoLayersWheel3")); + } + catch(...) { + std::cout << "ECalEndcapNumReadoutRhoLayersWheel3 not found in detector metadata, exiting..." << std::endl; + exit(1); + } - m_bladeAngle.clear(); - + m_numReadoutZLayers.clear(); try { - m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle1")); + m_numReadoutZLayers.push_back(dd4hepgeo->constant("ECalEndcapNumReadoutZLayersWheel1")); } catch(...) { - std::cout << "BladeAngle1 not found in detector metadata, exiting..." << std::endl; + std::cout << "ECalEndcapNumReadoutZLayersWheel1 not found in detector metadata, exiting..." << std::endl; exit(1); } try { - m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle2")); + m_numReadoutZLayers.push_back(dd4hepgeo->constant("ECalEndcapNumReadoutZLayersWheel2")); } catch(...) { - std::cout << "BladeAngle2 not found in detector metadata, exiting..." << std::endl; + std::cout << "ECalEndcapNumReadoutZLayersWheel2 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + try { + m_numReadoutZLayers.push_back(dd4hepgeo->constant("ECalEndcapNumReadoutZLayersWheel3")); + } + catch(...) { + std::cout << "ECalEndcapNumReadoutZLayersWheel3 not found in detector metadata, exiting..." << std::endl; exit(1); } + + m_numCalibRhoLayers.clear(); try { - m_bladeAngle.push_back(dd4hepgeo->constant("BladeAngle3")); + m_numCalibRhoLayers.push_back(dd4hepgeo->constant("ECalEndcapNumCalibRhoLayersWheel1")); } catch(...) { - std::cout << "BladeAngle3 not found in detector metadata, exiting..." << std::endl; + std::cout << "ECalEndcapNumCalibRhoLayersWheel1 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + try { + m_numCalibRhoLayers.push_back(dd4hepgeo->constant("ECalEndcapNumCalibRhoLayersWheel2")); + } + catch(...) { + std::cout << "ECalEndcapNumCalibRhoLayersWheel2 not found in detector metadata, exiting..." << std::endl; + exit(1); + } + try { + m_numCalibRhoLayers.push_back(dd4hepgeo->constant("ECalEndcapNumCalibRhoLayersWheel3")); + } + catch(...) { + std::cout << "ECalEndcapNumCalibRhoLayersWheel3 not found in detector metadata, exiting..." << std::endl; exit(1); } - - m_nUnitCells.clear(); + m_numCalibZLayers.clear(); try { - m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells1")); + m_numCalibZLayers.push_back(dd4hepgeo->constant("ECalEndcapNumCalibZLayersWheel1")); } catch(...) { - std::cout << "nUnitCells1 not found in detector metadata, exiting..." << std::endl; + std::cout << "ECalEndcapNumCalibZLayersWheel1 not found in detector metadata, exiting..." << std::endl; exit(1); } try { - m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells2")); + m_numCalibZLayers.push_back(dd4hepgeo->constant("ECalEndcapNumCalibZLayersWheel2")); } catch(...) { - std::cout << "nUnitCells2 not found in detector metadata, exiting..." << std::endl; + std::cout << "ECalEndcapNumCalibZLayersWheel2 not found in detector metadata, exiting..." << std::endl; exit(1); } try { - m_nUnitCells.push_back(dd4hepgeo->constant("nUnitCells3")); + m_numCalibZLayers.push_back(dd4hepgeo->constant("ECalEndcapNumCalibZLayersWheel3")); } catch(...) { - std::cout << "nUnitCells3 not found in detector metadata, exiting..." << std::endl; + std::cout << "ECalEndcapNumCalibZLayersWheel3 not found in detector metadata, exiting..." << std::endl; exit(1); } } - + /// determine the local position based on the cell ID Vector3D FCCSWEndcapTurbine_k4geo::position(const CellID& cID) const { - // double rhoVal = rho(cID); // just the center of the blade + double rhoVal = rho(cID); double zVal = z(cID); double phiVal = phi(cID); - double xVal = x(cID); - - //Vector3D pos = PositionRhoZPhi(rhoVal, zVal, phiVal); + Vector3D pos = PositionRhoZPhi(rhoVal, zVal, phiVal); + // account for the fact that the -z endcap is mirrored wrt to the +z one + if (pos.Z < 0.) pos.Y = -pos.Y; - // make a dummy "position" vector that has phi, x, and z - Vector3D pos(phiVal, 0., 0); - - // // account for the fact that the -z endcap is mirrored wrt to the +z one - // if (pos.Z < 0.) pos.Y = -pos.Y; return pos; } @@ -159,59 +211,86 @@ Vector3D FCCSWEndcapTurbine_k4geo::position(const CellID& cID) const { CellID FCCSWEndcapTurbine_k4geo::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const { CellID cID = vID; + CellID iWheel = _decoder->get(cID, m_wheelID); + CellID iLayer = _decoder->get(cID, m_layerID); + double lRho = rhoFromXYZ(globalPosition); + unsigned iRho = positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]); + if (iRho < 0) iRho == 0; + if (iRho >= m_numReadoutRhoLayers[iWheel]) iRho = m_numReadoutRhoLayers[iWheel]-1; + + _decoder->set(cID, m_rhoID, iRho); - // _decoder->set(cID, m_rhoID, positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel])); - //_decoder->set(cID, m_rhoID, 0); + std::cout << " for tree: " << lRho << " " << TMath::Abs(globalPosition.Z) << " " << positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]) << " " << positionToBin(TMath::Abs(globalPosition.Z), m_gridSizeZ[iWheel], m_offsetZ[iWheel]) << " " << _decoder->get(cID, m_layerID) << std::endl; + std::cout << "rho bin is " << positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]) << " based on " << lRho << " " << m_gridSizeRho[iWheel] << " " << m_offsetRho[iWheel] << std::endl; double lZ = TMath::Abs(globalPosition.Z); - _decoder->set(cID, m_zID, positionToBin(lZ, m_gridSizeZ, m_offsetZ)); + unsigned iZ = positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel]); + if (iZ < 0) iZ == 0; + if (iZ >= m_numReadoutZLayers[iWheel]) iZ = m_numReadoutZLayers[iWheel]-1; + _decoder->set(cID, m_zID, iZ); + std::cout << "z bin is " << positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel]) << " based on " << lZ << " " << m_gridSizeZ[iWheel] << " " << m_offsetZ[iWheel] << " and layer is " << iLayer << " and cell ID is " << cID << std::endl; + + std::cout << "Expected, actual layer : " << expLayer(iWheel, positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]), positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel])) << " " << iLayer << std::endl; + if (expLayer(iWheel, iRho, iZ) != iLayer) { + _decoder->set(cID, m_layerID, expLayer(iWheel, iRho, iZ)); + } + return cID; } + /// determine rho based on the cell ID +double FCCSWEndcapTurbine_k4geo::rho(const CellID& cID) const { + CellID rhoValue = _decoder->get(cID, m_rhoID); + CellID iWheel = _decoder->get(cID, m_wheelID); + + if (iWheel == 0) { + std::cout << "rho value is " << binToPosition(rhoValue,m_gridSizeRho[iWheel], m_offsetRho[iWheel]) << " based on " << rhoValue << " " << m_gridSizeRho[iWheel] << " " << m_offsetRho[iWheel] << std::endl; + } + return binToPosition(rhoValue,m_gridSizeRho[iWheel], m_offsetRho[iWheel]); +} + /// determine the azimuthal angle phi based on the cell ID double FCCSWEndcapTurbine_k4geo::phi(const CellID& cID) const { - - // just return the phi of the module center CellID iModule = _decoder->get(cID, m_moduleID); CellID iWheel = _decoder->get(cID, m_wheelID); - CellID iSide = _decoder->get(cID, m_sideID); - - double phiCent = ((long long int)iSide)*twopi*(iModule)/m_nUnitCells[iWheel]; - - return phiCent; - //double rhoLoc = rho(cID); - //double zLoc = TMath::Abs(z(cID))-m_offsetZ - 45; // hard-code midpoint in z for now - - //double zCotBladeAngle = zLoc/TMath::Tan(m_bladeAngle[iWheel]); - // double x = zCotBladeAngle; - //double y = TMath::Sqrt(rhoLoc*rhoLoc - x*x); - //// rotate about z axis by phiCent - //double xprime = x*TMath::Cos(phiCent) +y*TMath::Sin(phiCent); - //double yprime = y*TMath::Cos(phiCent) -x*TMath::Sin(phiCent); - - //return TMath::ATan2(xprime,yprime); -} -/// determine the value of the x coordinate relative to the center of the blade - double FCCSWEndcapTurbine_k4geo::x(const CellID& cID) const { + double phiCent = twopi*(iModule+0.5)/m_nUnitCells[iWheel]; - CellID iWheel = _decoder->get(cID, m_wheelID); - double zLoc = TMath::Abs(z(cID))-m_offsetZ - 45; // hard-code midpoint in z for now + double rhoLoc = rho(cID); + double zLoc = TMath::Abs(z(cID))-m_offsetZ[iWheel] - 45/2.; // hard-code midpoint in z for now - double zCotBladeAngle = zLoc/TMath::Tan(m_bladeAngle[iWheel]); - double x = zCotBladeAngle; + std::cout << "zLoc is " << zLoc << std::endl; + double zCotBladeAngle = zLoc/TMath::Tan(m_bladeAngle[iWheel]); - return x; -} + double x = zCotBladeAngle; + double y = TMath::Sqrt(rhoLoc*rhoLoc - x*x); + // rotate about z axis by phiCent + double xprime = x*TMath::Cos(phiCent) +y*TMath::Sin(phiCent); + double yprime = y*TMath::Cos(phiCent) -x*TMath::Sin(phiCent); + + return TMath::ATan2(xprime,yprime); + } /// determine local x in plane of blade based on the cell ID double FCCSWEndcapTurbine_k4geo::z(const CellID& cID) const { CellID zValue = _decoder->get(cID, m_zID); CellID sideValue = _decoder->get(cID, m_sideID); - return ((long long int)sideValue)*binToPosition(zValue,m_gridSizeZ,m_offsetZ); + CellID iWheel = _decoder->get(cID, m_wheelID); + return ((long long int)sideValue)*binToPosition(zValue,m_gridSizeZ[iWheel],m_offsetZ[iWheel]); } + /// determine expected layer value based on wheel, rho, and z indices + unsigned FCCSWEndcapTurbine_k4geo::expLayer(unsigned iWheel, unsigned iRho, unsigned iZ) const { + unsigned layerOffset = 0; + if (iWheel == 1) { + layerOffset = m_numCalibZLayers[0]*m_numCalibRhoLayers[0]; + } + else if (iWheel == 2) { + layerOffset = m_numCalibZLayers[0]*m_numCalibRhoLayers[0]+layerOffset + m_numCalibZLayers[1]*m_numCalibRhoLayers[1]; + } + return layerOffset + iZ/(m_numReadoutZLayers[iWheel]/m_numCalibZLayers[iWheel]) + iRho*m_numCalibZLayers[iWheel]/(m_numReadoutRhoLayers[iWheel]/m_numCalibRhoLayers[iWheel]); + } } } From 47e59a2c29c010b5e56ff1d41605e02a76897a7c Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Sat, 11 Jan 2025 21:39:14 -0700 Subject: [PATCH 43/59] Fix a few typos --- detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp index 302eb1beb..69c53151b 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp @@ -87,7 +87,8 @@ namespace det { dd4hep::xml::DetElement nobleLiquidElem = genericBladeElem.child(_Unicode(nobleLiquidGap)); float BladeAngle = 0.0, AbsThickMin = 0.0, BladeThicknessScaleFactor=0.0; - + int nUnitCells = -1; + // hardcode for three wheels if (iWheel == 0) { BladeAngle = genericBladeElem.attr(_Unicode(angle1)); @@ -133,12 +134,10 @@ namespace det { float ElectrodeThick = electrodeBladeElem.attr(_Unicode(thickness)); float LArgapi = nobleLiquidElem.attr(_Unicode(gap)); -<<<<<<< HEAD bool sameNUnitCells = genericBladeElem.attr(_Unicode(sameNUnitCells)); char* nUnitCellsStrArr = (char*)genericBladeElem.attr(_Unicode(nUnitCells)).c_str(); char* nUnitCellsCStr = strtok(nUnitCellsStrArr, " "); - int nUnitCells = -1; if (!sameNUnitCells) { for (unsigned i = 0; i < iWheel; i++) { @@ -147,8 +146,6 @@ namespace det { std::string nUnitCellsStr = nUnitCellsCStr; nUnitCells = std::stoi(nUnitCellsStr); } -======= ->>>>>>> c85fb7c2 (Fix bugs in LAr bath placement and in placement of passive elements when split into layers) dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "nUnitCells: %d", nUnitCells); From c78d3ba44edc11a6f8bdf27cf92d123b913b860d Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Sun, 12 Jan 2025 16:25:06 -0700 Subject: [PATCH 44/59] Fix compiler warnings --- detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp | 3 --- detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp index 2084512ce..2b21d5a7a 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp @@ -212,9 +212,6 @@ namespace det { float delrNonActive = (ro-ri)/numNonActiveRhoLayers; float delrActive = (ro-ri)/ECalEndcapNumCalibRhoLayers; - float delzNonActive = delZ/numNonActiveZLayers; - float delzActive = delZ/ECalEndcapNumCalibZLayers; - for (unsigned iRhoLayer = 0; iRhoLayer < numNonActiveRhoLayers; iRhoLayer++) { float roLayer = riLayer + delrNonActive; dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Making layer with inner, outer radii %f, %f", riLayer, roLayer); diff --git a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp index da8da0c4d..dfb95efbe 100644 --- a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp +++ b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp @@ -214,8 +214,8 @@ CellID FCCSWEndcapTurbine_k4geo::cellID(const Vector3D& /* localPosition */, con CellID iWheel = _decoder->get(cID, m_wheelID); CellID iLayer = _decoder->get(cID, m_layerID); double lRho = rhoFromXYZ(globalPosition); - unsigned iRho = positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]); - if (iRho < 0) iRho == 0; + int iRho = positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]); + if (iRho < 0) iRho = 0; if (iRho >= m_numReadoutRhoLayers[iWheel]) iRho = m_numReadoutRhoLayers[iWheel]-1; _decoder->set(cID, m_rhoID, iRho); @@ -223,8 +223,8 @@ CellID FCCSWEndcapTurbine_k4geo::cellID(const Vector3D& /* localPosition */, con std::cout << " for tree: " << lRho << " " << TMath::Abs(globalPosition.Z) << " " << positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]) << " " << positionToBin(TMath::Abs(globalPosition.Z), m_gridSizeZ[iWheel], m_offsetZ[iWheel]) << " " << _decoder->get(cID, m_layerID) << std::endl; std::cout << "rho bin is " << positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]) << " based on " << lRho << " " << m_gridSizeRho[iWheel] << " " << m_offsetRho[iWheel] << std::endl; double lZ = TMath::Abs(globalPosition.Z); - unsigned iZ = positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel]); - if (iZ < 0) iZ == 0; + int iZ = positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel]); + if (iZ < 0) iZ = 0; if (iZ >= m_numReadoutZLayers[iWheel]) iZ = m_numReadoutZLayers[iWheel]-1; _decoder->set(cID, m_zID, iZ); std::cout << "z bin is " << positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel]) << " based on " << lZ << " " << m_gridSizeZ[iWheel] << " " << m_offsetZ[iWheel] << " and layer is " << iLayer << " and cell ID is " << cID << std::endl; From ea98f17eac1ec926982799be5af72a27a74e25a5 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Mon, 13 Jan 2025 10:49:28 -0700 Subject: [PATCH 45/59] Update nominal detector model for turbing ecal endcap --- .../ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml | 83 ++++++++++++------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml index ac5b7f2ef..3f0fc845f 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml @@ -40,23 +40,54 @@ - - + + + + + + + + + + + + - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + - - + + + + @@ -73,16 +104,11 @@ - - - system:4,cryo:1,type:3,subtype:3,side:-2,wheel:3,layer:8,module:17,rho:8,z:8 + + system:4,cryo:1,type:3,subtype:3,side:-2,wheel:3,layer:12,module:11,rho:8,z:8 - --> + - + - + - - - + + + + - + - - + + @@ -128,7 +155,7 @@ - + From b624efe65c6097ff5b9fa4f6beabe86e27d57494 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Mon, 13 Jan 2025 10:49:49 -0700 Subject: [PATCH 46/59] remove cout's --- detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp index dfb95efbe..ab5a43628 100644 --- a/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp +++ b/detectorSegmentations/src/FCCSWEndcapTurbine_k4geo.cpp @@ -220,16 +220,11 @@ CellID FCCSWEndcapTurbine_k4geo::cellID(const Vector3D& /* localPosition */, con _decoder->set(cID, m_rhoID, iRho); - std::cout << " for tree: " << lRho << " " << TMath::Abs(globalPosition.Z) << " " << positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]) << " " << positionToBin(TMath::Abs(globalPosition.Z), m_gridSizeZ[iWheel], m_offsetZ[iWheel]) << " " << _decoder->get(cID, m_layerID) << std::endl; - std::cout << "rho bin is " << positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]) << " based on " << lRho << " " << m_gridSizeRho[iWheel] << " " << m_offsetRho[iWheel] << std::endl; double lZ = TMath::Abs(globalPosition.Z); int iZ = positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel]); if (iZ < 0) iZ = 0; if (iZ >= m_numReadoutZLayers[iWheel]) iZ = m_numReadoutZLayers[iWheel]-1; _decoder->set(cID, m_zID, iZ); - std::cout << "z bin is " << positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel]) << " based on " << lZ << " " << m_gridSizeZ[iWheel] << " " << m_offsetZ[iWheel] << " and layer is " << iLayer << " and cell ID is " << cID << std::endl; - - std::cout << "Expected, actual layer : " << expLayer(iWheel, positionToBin(lRho, m_gridSizeRho[iWheel], m_offsetRho[iWheel]), positionToBin(lZ, m_gridSizeZ[iWheel], m_offsetZ[iWheel])) << " " << iLayer << std::endl; if (expLayer(iWheel, iRho, iZ) != iLayer) { _decoder->set(cID, m_layerID, expLayer(iWheel, iRho, iZ)); @@ -243,9 +238,6 @@ double FCCSWEndcapTurbine_k4geo::rho(const CellID& cID) const { CellID rhoValue = _decoder->get(cID, m_rhoID); CellID iWheel = _decoder->get(cID, m_wheelID); - if (iWheel == 0) { - std::cout << "rho value is " << binToPosition(rhoValue,m_gridSizeRho[iWheel], m_offsetRho[iWheel]) << " based on " << rhoValue << " " << m_gridSizeRho[iWheel] << " " << m_offsetRho[iWheel] << std::endl; - } return binToPosition(rhoValue,m_gridSizeRho[iWheel], m_offsetRho[iWheel]); } @@ -255,11 +247,9 @@ double FCCSWEndcapTurbine_k4geo::phi(const CellID& cID) const { CellID iWheel = _decoder->get(cID, m_wheelID); double phiCent = twopi*(iModule+0.5)/m_nUnitCells[iWheel]; - double rhoLoc = rho(cID); double zLoc = TMath::Abs(z(cID))-m_offsetZ[iWheel] - 45/2.; // hard-code midpoint in z for now - std::cout << "zLoc is " << zLoc << std::endl; double zCotBladeAngle = zLoc/TMath::Tan(m_bladeAngle[iWheel]); double x = zCotBladeAngle; From 5067ae60217fee4beace26f1df56c122d4ed823f Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Wed, 15 Jan 2025 08:52:42 -0700 Subject: [PATCH 47/59] Change NL to LAr --- FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml index 3f0fc845f..f54906b22 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml @@ -155,7 +155,7 @@ - + From 4c69880e1c1057a4e86f93f8ff500707838dcafa Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 16 Jan 2025 12:33:13 -0700 Subject: [PATCH 48/59] Update with description of v03 --- detector/calorimeter/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/detector/calorimeter/README.md b/detector/calorimeter/README.md index f55823bf7..d02441363 100644 --- a/detector/calorimeter/README.md +++ b/detector/calorimeter/README.md @@ -30,7 +30,10 @@ Sub-detector for the ecal endcaps, with the absorbers and readout boards arrange Initial implementation. A custom segmentation that creates readout cells and constant radius and z is also included (FCCSWEndcapTurbine_k4geo). ### o1_v02 -Changes wrt o1_v01: Added flexibility to configure the wheels individual (to allow for example the possibiliity of having different blade angles in each). This is still a work in progress, so o1_v01 should be used for integrated tests. +Changes wrt o1_v01: Added flexibility to configure the wheels individual (to allow for example the possibiliity of having different blade angles in each). + +### o1_v03 +Changes wrt o1_v02: Modified the calibration "layers" to be a 2d grid in both dimensions on the surface of an absorber plate (which map to the rho and z dimensions in the global coordinate system), since the NL gap varies in both directions. The readout segmentation is also a 2d grid in the same coordinates, but the readout is allowed to be finer-grained than the calibration. ## HCalTileBarrel This sub-detector makes calorimeter barrel. It is used in ALLEGRO detector concept. From 5924b0d0b77020e4fcc4830237b4d950700e37d7 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Tue, 28 Jan 2025 11:13:33 -0700 Subject: [PATCH 49/59] Add some new accessor function --- .../include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h b/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h index 51e172675..61b56b5eb 100644 --- a/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h +++ b/detectorSegmentations/include/detectorSegmentations/FCCSWEndcapTurbine_k4geo.h @@ -84,6 +84,11 @@ class FCCSWEndcapTurbine_k4geo : public Segmentation { * return The field name for phi. */ inline const std::string& fieldNamePhi() const { return m_phiID; } + /** Get the angle of the turbine blades in a given wheel + * @param[in] iWheel index of wheel. + * return the blade angle for the requested wheel + */ + double bladeAngle(unsigned iWheel) const {return m_bladeAngle[iWheel];} /** Set the number of bins in azimuthal angle. * @param[in] aNumberBins Number of bins in phi. */ From 708fed6ea4f5d451a687d8ec7970dc72e87d8e25 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Wed, 29 Jan 2025 11:11:14 -0700 Subject: [PATCH 50/59] Proper calibration xml --- .../ECalEndcaps_Turbine_calibration.xml | 81 ++++++++++++------- 1 file changed, 54 insertions(+), 27 deletions(-) diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine_calibration.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine_calibration.xml index 1df7dd3af..c23ec59a1 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine_calibration.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine_calibration.xml @@ -32,23 +32,54 @@ - - + + + + + + + + + + + + - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + - - + + + + @@ -65,16 +96,11 @@ - - - system:4,cryo:1,type:3,subtype:3,side:-2,wheel:3,layer:8,module:17,rho:8,z:8 + + system:4,cryo:1,type:3,subtype:3,side:-2,wheel:3,layer:12,module:11,rho:8,z:8 - --> + - + - + - - - + + + + - + - - + + From 81b31ee2e5a5203c6a6125d42f1635ed22275e4b Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:30:53 -0700 Subject: [PATCH 51/59] Remove unintentional changes --- .../compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml index c55d34dbd..cd012cdf4 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalBarrel_TileCal_v02.xml @@ -52,11 +52,6 @@ system:4,layer:5,theta:9,phi:10 - - - - system:4,layer:5,row:9,theta:0,phi:10 - From 968c584a0adea7d50c09843c221f84234857bffa Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:31:17 -0700 Subject: [PATCH 52/59] Remove unintentional changes --- .../HCalEndcaps_ThreeParts_TileCal_v02.xml | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalEndcaps_ThreeParts_TileCal_v02.xml b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalEndcaps_ThreeParts_TileCal_v02.xml index ea48314a7..06fa8d510 100644 --- a/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalEndcaps_ThreeParts_TileCal_v02.xml +++ b/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/HCalEndcaps_ThreeParts_TileCal_v02.xml @@ -44,20 +44,19 @@ - - system:4,type:2,layer:5,row:9,eta:11,phi:10 + + system:4,type:3,layer:6,row:11,theta:11,phi:10 - - - system:4,type:2,layer:4,eta:11,phi:10 - - - - - system:4,type:2,layer:5,row:9,eta:10,phi:10 + + + system:4,type:3,layer:6,theta:11,phi:10 + + @@ -70,25 +69,25 @@ From 58d069ca030287d0baeb6de44ab0a10f205dc7da Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:32:01 -0700 Subject: [PATCH 53/59] Remove unintentional changes --- FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml b/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml index 37f6a984d..54c8af2f4 100644 --- a/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml +++ b/FCCee/CLD/compact/CLD_o2_v07/LumiCal_o3_v02_05.xml @@ -157,6 +157,7 @@ outer_r = "LumiCal_Shield_outer_radius" inner_z = "LumiCal_max_z - LumiCal_shield_dz_prime + LumiCal_shield_dz"/> + From 2c9ac1dfe4188c3f6f5e4f5996cd39ca4edf4836 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:32:38 -0700 Subject: [PATCH 54/59] Remove commented code --- .../ECalEndcap_Turbine_o1_v02_geo.cpp | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp index 69c53151b..9abf31e31 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v02_geo.cpp @@ -176,7 +176,6 @@ namespace det { leftoverS = (circ - nUnitCells*delrPhiNoGap); delrPhiGapOnly = leftoverS/(2*nUnitCells); float LArgapo = delrPhiGapOnly*TMath::Sin(BladeAngle); - // LArgapo *= 2.; dd4hep::Solid absBlade; float riLayer = ri; @@ -226,10 +225,8 @@ namespace det { dd4hep::Solid glueLayer = buildOneBlade(AbsThicki+GlueThick, AbsThicko+GlueThick, xRange, roLayer, riLayer, BladeAngle, delZ ); - // dd4hep::SubtractionSolid claddingLayer(absGlueCladdingLayer, absGlueLayer); dd4hep::Solid absBladeLayer = buildOneBlade(AbsThicki, AbsThicko, xRange, roLayer, riLayer, BladeAngle, delZ ); - // dd4hep::SubtractionSolid glueLayer(absGlueLayer, absBladeLayer); dd4hep::Volume claddingLayerVol("claddingLayer", claddingLayer, aLcdd.material(claddingElem.materialStr())); if (claddingElem.isSensitive()) { claddingLayerVol.setSensitiveDetector(aSensDet); @@ -285,7 +282,6 @@ namespace det { } electrodeBladeLayerVols.push_back(electrodeBladeLayerVol); - // dd4hep::SubtractionSolid LArShapeTotalLayer(electrodeBladeAndGapLayer, electrodeBladeLayer); dd4hep::Volume LArTotalLayerVol("LArTotalLayerVol", electrodeBladeAndGapLayer, aLcdd.material(nobleLiquidElem.materialStr())); if ( nobleLiquidElem.isSensitive() ) { @@ -300,7 +296,6 @@ namespace det { dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "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 = 1; dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "Number of unit cells %d", nUnitCells); @@ -314,7 +309,6 @@ namespace det { float roLayer = riLayer+delrNonActive; - //dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); dd4hep::Position posLayer(0,0,0); dd4hep::PlacedVolume absBladeVol_pv = glueLayerVols[iLayer].placeVolume(absBladeLayerVol, posLayer); @@ -343,9 +337,6 @@ namespace det { glueVol_pv.addPhysVolID("subtype", 1); // 1 = absorber, 2 = glue, 3 = cladding glueVol_pv.addPhysVolID("layer", iWheel*numNonActiveLayers+iLayer); - // dd4hep::DetElement glueDetElem(passiveDetElem, "glue_",ECalEndCapElementCounter++); - // glueDetElem.setPlacement(glueVol_pv); - dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Glue volume %s", glueVol_pv.toString().c_str()); riLayer = roLayer; iLayer++; @@ -370,8 +361,6 @@ namespace det { claddingVol_pv.addPhysVolID("layer", iWheel*numNonActiveLayers+iLayer); dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Cladding volume %s", claddingVol_pv.toString().c_str()); - // dd4hep::DetElement claddingDetElem(passiveDetElem, "cladding_", ECalEndCapElementCounter++); - // claddingDetElem.setPlacement(claddingVol_pv); riLayer = roLayer; iLayer++; @@ -465,7 +454,6 @@ namespace det { passivePhysVol.addPhysVolID("module", modIndex); passivePhysVol.addPhysVolID("wheel", iWheel); passivePhysVol.addPhysVolID("type", 1); // 0 = active, 1 = passive, 2 = readout - // dd4hep::DetElement passiveDetElem(bathDetElem, "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); dd4hep::DetElement passiveDetElem( "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); passiveDetElem.setPlacement(passivePhysVol); dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02_geo", "Passive volume %s", passivePhysVol.toString().c_str()); @@ -531,9 +519,6 @@ namespace det { double bathThicknessFront = aLcdd.constant("BathThicknessFront"); double bathThicknessBack = aLcdd.constant("BathThicknessBack"); - // double cryoThicknessInner = aLcdd.constant("CryoEMECThicknessInner"); - // double cryoThicknessOuter = aLcdd.constant("CryoEMECThicknessOuter"); - dd4hep::xml::DetElement cryoFront = cryostat.child(_Unicode(front)); dd4hep::xml::DetElement cryoBack = cryostat.child(_Unicode(back)); dd4hep::xml::DetElement cryoInner = cryostat.child(_Unicode(inner)); @@ -548,8 +533,7 @@ namespace det { double bathRmax = cryoDim.rmax1(); // + margin for inclination double bathDelZ = cryoDim.dz(); 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 - + dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "Cryostat front thickness is %f", cryoDim.rmin2() ); if (cryoThicknessFront > 0) { @@ -558,7 +542,6 @@ namespace det { dd4hep::Tube cryoBackShape(cryoDim.rmin2(), cryoDim.rmax2(), cryoThicknessBack/2.); dd4hep::Tube cryoInnerShape(cryoDim.rmin1(), cryoDim.rmin2(), cryoDim.dz()); dd4hep::Tube cryoOuterShape(cryoDim.rmax1(), cryoDim.rmax2(), cryoDim.dz()); - // dd4hep::SubtractionSolid cryoSideShape(cryoSideOuterShape, bathAndServicesOuterShape); dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v02", "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_v02", "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_v02", "ECAL endcap cryostat: side: rmin (cm) = %f rmax (cm) = %f dz (cm) = %f", cryoDim.rmin2(), cryoDim.rmax1(), cryoDim.dz() - caloDim.dz()); @@ -650,7 +633,6 @@ namespace det { } dd4hep::PlacedVolume supportTube_pv = bathVol.placeVolume(supportTubeVol, dd4hep::Position(0,0,zOffsetEnvelope + dim.dz() )); supportTube_pv.addPhysVolID("cryo", 1); - // supportTube_pv.addPhysVolID("side",sign); supportTube_pv.addPhysVolID("wheel", iWheel); dd4hep::DetElement supportTubeDetElem(bathDetElem, "supportTube_"+std::to_string(iWheel), 0); supportTubeDetElem.setPlacement(supportTube_pv); @@ -692,9 +674,6 @@ namespace det { dd4hep::Volume envelopeVol(nameDet + "_vol", endcapShape, aLcdd.material("Air")); - // dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0); - // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); - dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v02", "Placing detector on the positive side: (cm) %f with min, max radii %f %f",dim.z_offset(), dim.rmin1(), dim.rmax1() ); unsigned iModule = 0; @@ -707,18 +686,12 @@ namespace det { dd4hep::PlacedVolume envelopePositivePhysVol = endcapsAssembly.placeVolume(envelopeVol, envelopePositiveVolume_tr); envelopePositivePhysVol.addPhysVolID("side", 1); - // dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0); - // caloPositiveDetElem.setPlacement(envelopePositivePhysVol); - // make another placement for the negative z endcap dd4hep::Transform3D envelopeNegativeVolume_tr(dd4hep::RotationZYX( 0 ,0,180*dd4hep::deg), dd4hep::Translation3D(0, 0, -dim.z_offset())); dd4hep::PlacedVolume envelopeNegativePhysVol = endcapsAssembly.placeVolume(envelopeVol, envelopeNegativeVolume_tr); envelopeNegativePhysVol.addPhysVolID("side", -1); - // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); - //caloNegativeDetElem.setPlacement(envelopeNegativePhysVol); - dd4hep::Volume motherVol = aLcdd.pickMotherVolume(caloDetElem); dd4hep::PlacedVolume envelopePhysVol = motherVol.placeVolume(endcapsAssembly); caloDetElem.setPlacement(envelopePhysVol); From c0849a9825eb67cd327fd3672fa0e8a409a43186 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:33:12 -0700 Subject: [PATCH 55/59] Fix subtype numbering and remove commented code --- .../ECalEndcap_Turbine_o1_v03_geo.cpp | 38 ++----------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp index 2b21d5a7a..86a36d2ca 100644 --- a/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp +++ b/detector/calorimeter/ECalEndcap_Turbine_o1_v03_geo.cpp @@ -30,10 +30,6 @@ namespace det { double d = c*c*r*r/(1+c*c); return (TMath::Sqrt(d)-zp)*TMath::Sin(bladeangle); - // try approximating the arclength as dx. Less accurate, but that - // approximation is used in calculating the LAr gap, so maybe this - // will make it more consistent? - //return s*TMath::Sin(bladeangle); } @@ -228,10 +224,8 @@ namespace det { dd4hep::Solid glueLayer = buildOneBlade(AbsThicki+GlueThick, AbsThicko+GlueThick, xRange/numNonActiveZLayers, roLayer, riLayer, BladeAngle, delZ, zStart ); - // dd4hep::SubtractionSolid claddingLayer(absGlueCladdingLayer, absGlueLayer); dd4hep::Solid absBladeLayer = buildOneBlade(AbsThicki, AbsThicko, xRange/numNonActiveZLayers, roLayer, riLayer, BladeAngle, delZ, zStart ); - // dd4hep::SubtractionSolid glueLayer(absGlueLayer, absBladeLayer); dd4hep::Volume claddingLayerVol("claddingLayer", claddingLayer, aLcdd.material(claddingElem.materialStr())); if (claddingElem.isSensitive()) { claddingLayerVol.setSensitiveDetector(aSensDet); @@ -296,7 +290,6 @@ namespace det { } electrodeBladeLayerVols.push_back(electrodeBladeLayerVol); - // dd4hep::SubtractionSolid LArShapeTotalLayer(electrodeBladeAndGapLayer, electrodeBladeLayer); dd4hep::Volume LArTotalLayerVol("LArTotalLayerVol", electrodeBladeAndGapLayer, aLcdd.material(nobleLiquidElem.materialStr())); if ( nobleLiquidElem.isSensitive() ) { @@ -314,7 +307,6 @@ namespace det { dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "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 = 5; dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Number of unit cells %d", nUnitCells); @@ -330,12 +322,11 @@ namespace det { float roLayer = riLayer+delrNonActive; - //dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); dd4hep::Position posLayer(0,0,0); xOffset += xRange/numNonActiveZLayers; dd4hep::PlacedVolume absBladeVol_pv = glueLayerVols[iLayer].placeVolume(absBladeLayerVol, posLayer); - absBladeVol_pv.addPhysVolID("subtype", 4); // 1 = absorber, 2 = glue, 3 = cladding + absBladeVol_pv.addPhysVolID("subtype", 1); // 1 = absorber, 2 = glue, 3 = cladding dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Blade layer, rho is %d, %f, %f", iLayer, absBladeVol_pv.position().Rho(), roLayer/2.); absBladeVol_pv.addPhysVolID("layer", LayerIndexBaseline+iLayer); @@ -359,17 +350,13 @@ namespace det { float roLayer = riLayer+delrNonActive; - // dd4hep::Position posLayer(0,0,(riLayer-ri+roLayer-ro)/2.); dd4hep::Position posLayer(0,xOffset/2.,0); dd4hep::PlacedVolume glueVol_pv = claddingLayerVols[iLayer].placeVolume(glueLayerVol, posLayer); xOffset += xRange/numNonActiveZLayers; - glueVol_pv.addPhysVolID("subtype", 1); // 1 = absorber, 2 = glue, 3 = cladding + glueVol_pv.addPhysVolID("subtype", 2); // 1 = absorber, 2 = glue, 3 = cladding glueVol_pv.addPhysVolID("layer", LayerIndexBaseline+iLayer); - // dd4hep::DetElement glueDetElem(passiveDetElem, "glue_",ECalEndCapElementCounter++); - // glueDetElem.setPlacement(glueVol_pv); - dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Glue volume %s", glueVol_pv.toString().c_str()); iLayer++; @@ -397,12 +384,10 @@ namespace det { xOffset += xRange/numNonActiveZLayers; dd4hep::PlacedVolume claddingVol_pv = passiveVol.placeVolume(claddingLayerVol, posLayer); - claddingVol_pv.addPhysVolID("subtype", 2); // 1 = absorber, 2 = glue, 3 = cladding + claddingVol_pv.addPhysVolID("subtype", 3); // 1 = absorber, 2 = glue, 3 = cladding claddingVol_pv.addPhysVolID("layer", LayerIndexBaseline+iLayer); dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Cladding volume %s", claddingVol_pv.toString().c_str()); - // dd4hep::DetElement claddingDetElem(passiveDetElem, "cladding_", ECalEndCapElementCounter++); - // claddingDetElem.setPlacement(claddingVol_pv); iLayer++; if (iLayer % numNonActiveZLayers ==0) { @@ -517,7 +502,6 @@ namespace det { passivePhysVol.addPhysVolID("module", modIndex); passivePhysVol.addPhysVolID("wheel", iWheel); passivePhysVol.addPhysVolID("type", 1); // 0 = active, 1 = passive, 2 = readout - // dd4hep::DetElement passiveDetElem(bathDetElem, "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); dd4hep::DetElement passiveDetElem( "passive_" + std::to_string(iUnitCell)+"_"+std::to_string(iWheel), ECalEndCapElementCounter++); passiveDetElem.setPlacement(passivePhysVol); dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03_geo", "Passive volume %s", passivePhysVol.toString().c_str()); @@ -570,7 +554,6 @@ namespace det { dd4hep::xml::DetElement xmlDetElem = aXmlElement; std::string nameDet = xmlDetElem.nameStr(); - // dd4hep::DetElement caloDetElem(nameDet, xmlDetElem.id()); dd4hep::xml::Dimension dim(aXmlElement.child(_Unicode(dimensions))); @@ -583,9 +566,6 @@ namespace det { double bathThicknessFront = aLcdd.constant("BathThicknessFront"); double bathThicknessBack = aLcdd.constant("BathThicknessBack"); - // double cryoThicknessInner = aLcdd.constant("CryoEMECThicknessInner"); - // double cryoThicknessOuter = aLcdd.constant("CryoEMECThicknessOuter"); - dd4hep::xml::DetElement cryoFront = cryostat.child(_Unicode(front)); dd4hep::xml::DetElement cryoBack = cryostat.child(_Unicode(back)); dd4hep::xml::DetElement cryoInner = cryostat.child(_Unicode(inner)); @@ -600,7 +580,6 @@ namespace det { double bathRmax = cryoDim.rmax1(); // + margin for inclination double bathDelZ = cryoDim.dz(); 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 dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "Cryostat front thickness is %f", cryoDim.rmin2() ); @@ -610,7 +589,6 @@ namespace det { dd4hep::Tube cryoBackShape(cryoDim.rmin2(), cryoDim.rmax2(), cryoThicknessBack/2.); dd4hep::Tube cryoInnerShape(cryoDim.rmin1(), cryoDim.rmin2(), cryoDim.dz()); dd4hep::Tube cryoOuterShape(cryoDim.rmax1(), cryoDim.rmax2(), cryoDim.dz()); - // dd4hep::SubtractionSolid cryoSideShape(cryoSideOuterShape, bathAndServicesOuterShape); dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v03", "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_v03", "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_v03", "ECAL endcap cryostat: side: rmin (cm) = %f rmax (cm) = %f dz (cm) = %f", cryoDim.rmin2(), cryoDim.rmax1(), cryoDim.dz() - caloDim.dz()); @@ -706,7 +684,6 @@ namespace det { } dd4hep::PlacedVolume supportTube_pv = bathVol.placeVolume(supportTubeVol, dd4hep::Position(0,0,zOffsetEnvelope + dim.dz() )); supportTube_pv.addPhysVolID("cryo", 1); - // supportTube_pv.addPhysVolID("side",sign); supportTube_pv.addPhysVolID("wheel", iWheel); dd4hep::DetElement supportTubeDetElem(bathDetElem, "supportTube_"+std::to_string(iWheel), 0); supportTubeDetElem.setPlacement(supportTube_pv); @@ -777,9 +754,6 @@ namespace det { dd4hep::Volume envelopeVol(nameDet + "_vol", endcapShape, aLcdd.material("Air")); - // dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0); - // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); - dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v03", "Placing detector on the positive side: (cm) %f with min, max radii %f %f",dim.z_offset(), dim.rmin1(), dim.rmax1() ); unsigned iModule = 0; @@ -791,9 +765,6 @@ namespace det { dd4hep::Transform3D envelopePositiveVolume_tr(dd4hep::RotationZYX( 0 ,0,0), dd4hep::Translation3D(0, 0, dim.z_offset())); dd4hep::PlacedVolume envelopePositivePhysVol = endcapsAssembly.placeVolume(envelopeVol, envelopePositiveVolume_tr); envelopePositivePhysVol.addPhysVolID("side", 1); - - // dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0); - // caloPositiveDetElem.setPlacement(envelopePositivePhysVol); // make another placement for the negative z endcap dd4hep::Transform3D envelopeNegativeVolume_tr(dd4hep::RotationZYX( 0 ,0,180*dd4hep::deg), dd4hep::Translation3D(0, 0, -dim.z_offset())); @@ -801,9 +772,6 @@ namespace det { endcapsAssembly.placeVolume(envelopeVol, envelopeNegativeVolume_tr); envelopeNegativePhysVol.addPhysVolID("side", -1); - // dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0); - //caloNegativeDetElem.setPlacement(envelopeNegativePhysVol); - dd4hep::Volume motherVol = aLcdd.pickMotherVolume(caloDetElem); dd4hep::PlacedVolume envelopePhysVol = motherVol.placeVolume(endcapsAssembly); caloDetElem.setPlacement(envelopePhysVol); From ff3b527a6382a20c0eedddcc8d8837bd3f59cf9c Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:33:41 -0700 Subject: [PATCH 56/59] Remove unintentional changes --- detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp b/detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp index 8ad039534..30235a955 100644 --- a/detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp +++ b/detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp @@ -422,6 +422,7 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h 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++){ DetElement layerDet(caloDetElem, dd4hep::xml::_toString(sign*(iLayer+1), "layer%d"), sign*(iLayer+1)); From 477b34045aded7974d2e0391e3008f94bb2b810c Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:34:38 -0700 Subject: [PATCH 57/59] Remove duplicated lines --- detector/calorimeter/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/detector/calorimeter/README.md b/detector/calorimeter/README.md index d02441363..a61677543 100644 --- a/detector/calorimeter/README.md +++ b/detector/calorimeter/README.md @@ -44,9 +44,6 @@ Original version taken from [FCCDetectors](https://github.com/HEP-FCC/FCCDetecto ### o1_v02 Changes wrt o1_v01: Added extension (LayeredCalorimeterData) to store radial layer radii and dimensions. Added several checks for the geometry building and made small changes in the code to improve readibility. -### o1_v02 -Changes wrt o1_v01: Added extension (LayeredCalorimeterData) to store radial layer radii and dimensions. Added several checks for the geometry building and made small changes in the code to improve readibility. - ## HCalThreePartsEndcap This sub-detector makes calorimeter endcaps. Each endcap is made up by three cylindrical pieces with different thickness and inner radius, but same outer radius. It is used in ALLEGRO detector concept. From 8e3f845648639a403b32690677c2c16e62904fed Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:35:28 -0700 Subject: [PATCH 58/59] Remove unintentional changes --- detector/tracker/TrackerBarrel_o1_v06_geo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp index 4d684d7cf..9ba5c30f0 100644 --- a/detector/tracker/TrackerBarrel_o1_v06_geo.cpp +++ b/detector/tracker/TrackerBarrel_o1_v06_geo.cpp @@ -152,6 +152,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s xml_comp_t x_mod = mi; xml_comp_t m_env = x_mod.child(_U(module_envelope)); std::string m_nam = x_mod.nameStr(); + if ( volumes.find(m_nam) != volumes.end() ) { printout(ERROR,"TrackerBarrel","Logics error in building modules."); @@ -212,7 +213,6 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s // int type = x_layer.type(); std::string m_nam = x_layer.moduleStr(); std::string lay_nam = _toString(x_layer.id(),"layer%d"); - Assembly lay_vol (lay_nam); // Create the layer envelope volume. double phi0 = x_layout.phi0(); // Starting phi of first sensor. double phi_tilt = x_layout.phi_tilt(); // Phi tilt of a sensor. @@ -254,6 +254,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s staveElementTemplate.add(sensorElement); sensorElement.setPlacement(sensorPv); + // also add a DetElement for the sensitive component for (const PlacedVolume& wafer_pv : waferVols) { DetElement comp_elt(sensorElement, wafer_pv.volume().name(), i); comp_elt.setPlacement(wafer_pv); @@ -301,7 +302,6 @@ static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector s /////////////////// } - } // Create the PhysicalVolume for the layer. pv = envelope.placeVolume(lay_vol); // Place layer in mother From 6e2701e08ba5d06dfe5bc65360bf07a2ed0ad671 Mon Sep 17 00:00:00 2001 From: Erich Varnes Date: Thu, 30 Jan 2025 18:35:51 -0700 Subject: [PATCH 59/59] Remove unintentional changes --- test/CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 29c9ebd4b..79ded71e7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -128,16 +128,6 @@ endif() # SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 600) #endif() -#-------------------------------------------------- -# test for IDEA o1 v03, with DRC -if(DCH_INFO_H_EXIST) -SET( test_name "test_IDEA_with_DRC_o1_v03" ) -ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" - ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/IDEA_withDRC_o1_v03.xml --steeringFile=${CMAKE_CURRENT_SOURCE_DIR}/../example/SteeringFile_IDEA_o1_v03.py -G --gun.distribution uniform --random.seed 1988301045 ) - SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" TIMEOUT 600) -endif() - - #-------------------------------------------------- # test for ALLEGRO o1 v02 SET( test_name "test_ALLEGRO_o1_v02" )