From ed0f94db8968d45588275f429192c2ef7ec9ec02 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Wed, 19 Jul 2023 15:46:10 +0200 Subject: [PATCH 01/20] Copy the drift chamber files before deep modifications --- .../IDEA_o1_v01/BeamInstrumentation.xml | 36 + .../compact/IDEA_o1_v01/Beampipe.xml | 150 +++ .../compact/IDEA_o1_v01/Calorimeter.xml | 47 + .../compact/IDEA_o1_v01/DriftChamber.xml | 27 + .../IDEA_o1_v01/DriftChamber_materials.xml | 393 ++++++++ .../IDEA_o1_v01/DriftChamber_parameters.xml | 87 ++ .../IDEA_o1_v01/FCCee_DectDimensions.xml | 247 +++++ .../IDEA_o1_v01/FCCee_DectEmptyMaster.xml | 28 + .../IDEA_o1_v01/FCCee_DectMaster_v01.xml | 43 + .../compact/IDEA_o1_v01/HOMAbsorber.xml | 64 ++ .../compact/IDEA_o1_v01/LumiCal.xml | 191 ++++ .../compact/IDEA_o1_v01/elements.xml | 884 ++++++++++++++++++ .../compact/IDEA_o1_v01/materials.xml | 261 ++++++ .../DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 789 ++++++++++++++++ 14 files changed, 3247 insertions(+) create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/BeamInstrumentation.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/Beampipe.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/Calorimeter.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectEmptyMaster.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/HOMAbsorber.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/LumiCal.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/elements.xml create mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/materials.xml create mode 100644 Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/BeamInstrumentation.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/BeamInstrumentation.xml new file mode 100644 index 00000000..49647b2b --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/BeamInstrumentation.xml @@ -0,0 +1,36 @@ + + + + COmpensating and screening solenoids for FCCee + + + + + Beampipe Instrumentation + + + + + + +
+ + + + + + + + +
+ +
+ + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/Beampipe.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/Beampipe.xml new file mode 100644 index 00000000..b86af521 --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/Beampipe.xml @@ -0,0 +1,150 @@ + + + + A beampipe for FCCee, R(central) = 1.5 cm + + + + + + + + + + + + + + + + + + + + Part of beampipe made of Beryllium + + + + + + + +
+ +
+ + + + + + + + + + + + + Golden foil in the inner part of the Be beampipe + +
+ +
+ + Part of beampipe made of Copper + +
+ + + + + +
+ + + +
+ + +
+ + +Full Cone Tungsten Shield + + + + Before HOM space +
+ + After HOM space (1197.5*m - 1298.7*mm) +18 cm as solenoid is now closer to IP +
+ + +Asymmetric Tungsten Shield no Rotation + + + + +
+ + was 370 +
+ + one degree less, to fit lumical window +
+ +
+ + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/Calorimeter.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/Calorimeter.xml new file mode 100644 index 00000000..df85bf69 --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/Calorimeter.xml @@ -0,0 +1,47 @@ + + + + + A Dummy Calorimeter: to be rewritten based on the dual readout technology + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml new file mode 100644 index 00000000..c715c88b --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml @@ -0,0 +1,27 @@ + + + + Test Drift Chamber stack + + + + + + + + + + + + + + system:4,superLayer:5,ring:5,phi:11,hitorigin:3,stereo:1,layerInCell:2 + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml new file mode 100644 index 00000000..943c8b96 --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml @@ -0,0 +1,393 @@ + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml new file mode 100644 index 00000000..54c95a8c --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml new file mode 100644 index 00000000..8a85757e --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectEmptyMaster.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectEmptyMaster.xml new file mode 100644 index 00000000..4f43b14f --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectEmptyMaster.xml @@ -0,0 +1,28 @@ + + + + + + + + + + Use this one if you want to use official dimensions but only place one detector inside + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml new file mode 100644 index 00000000..6bcc1db8 --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml @@ -0,0 +1,43 @@ + + + + + + + + One stop shop for a baseline / the latest developments of the FCCee Detector concept. + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/HOMAbsorber.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/HOMAbsorber.xml new file mode 100644 index 00000000..862207ea --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/HOMAbsorber.xml @@ -0,0 +1,64 @@ + + + + Higher mode absorber for FCCee + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/LumiCal.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/LumiCal.xml new file mode 100644 index 00000000..15f0434e --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/LumiCal.xml @@ -0,0 +1,191 @@ + + + + LumiCal for FCCee detector based on CLD + + + + + + + + + + system:8,barrel:3,layer:8,slice:8,r:32:-16,phi:-16 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/elements.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/elements.xml new file mode 100644 index 00000000..f35eb345 --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/elements.xml @@ -0,0 +1,884 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/materials.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/materials.xml new file mode 100644 index 00000000..a899266c --- /dev/null +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/materials.xml @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp new file mode 100644 index 00000000..efab0c60 --- /dev/null +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -0,0 +1,789 @@ +/*****************************************************************************\ +* DD4hep geometry code for the central drift chamber of the IDEA detector * +* Author: Lorenzo Capriotti * +\*****************************************************************************/ +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "DD4hep/detail/DetectorInterna.h" +#include "TClass.h" +#include "TMath.h" +#include "XML/Utilities.h" +#include +#include +#include + +using namespace std; +using namespace dd4hep; + +struct wire + +{ + + dd4hep::Volume layer; + string type; + int num; + double radius; + double theta; + double thetaoffset; + double stereo; + double halfalpha; + double thickness; + double halflength; + dd4hep::Volume volume; +}; + +namespace { + +struct CDCHBuild : public dd4hep::xml::tools::VolumeBuilder { + std::vector deSuperLayer, deLayer, deSWire; + + CDCHBuild(dd4hep::Detector& description, xml_elt_t e, dd4hep::SensitiveDetector sens); + + double diff_of_squares(double a, double b); + void PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset, int SL, int iring, int wirenum); + void build_layer(DetElement parent, Volume parentVol); +}; + +// ****************************************************** +// Initializing constructor +// ****************************************************** + +CDCHBuild::CDCHBuild(dd4hep::Detector& dsc, xml_elt_t e, dd4hep::SensitiveDetector sens) + : dd4hep::xml::tools::VolumeBuilder(dsc, e, sens) {} + +double CDCHBuild::diff_of_squares(double a, double b) { + + double diff = pow(a, 2) - pow(b, 2); + return diff; +} + +void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset = 0, int SL = 999, + int iring = 999, int wirenum = -1) { + + dd4hep::RotationZYX rot(0., 0., w.stereo); + dd4hep::RotationX rot_stereo(w.stereo); + dd4hep::Position pos(w.radius, 0., 0.); + dd4hep::Translation3D transl(w.radius, 0., 0.); + + dd4hep::Transform3D T(transl * rot_stereo); + + string wirewrapname = "lvWireWrap_SL"; + wirewrapname += std::to_string(SL); + wirewrapname += "_ring"; + wirewrapname += std::to_string(iring); + wirewrapname += "_type"; + wirewrapname += w.type; + wirewrapname += "_stereo"; + wirewrapname += std::to_string(w.stereo); + + cout << "wirewrapname: " << wirewrapname << endl; + + string wirename = "lvWire_SL"; + wirename += std::to_string(SL); + wirename += "_ring"; + wirename += std::to_string(iring); + wirename += "_type"; + wirename += w.type; + wirename += "_stereo"; + wirename += std::to_string(w.stereo); + + dd4hep::Tube WrapTube(w.thickness, w.thickness + 0.5 * outwrap, halflength); + dd4hep::Volume lvWireWrapVol(wirewrapname, WrapTube, description.material("G4_Au")); + + dd4hep::Tube TotalWire(0.0, w.thickness + 0.5 * outwrap, halflength); + dd4hep::Volume lvWireVol(wirename, TotalWire, description.material("Air")); + + lvWireVol.placeVolume(w.volume, dd4hep::Position(0.0, 0.0, 0.0)); + lvWireVol.placeVolume(lvWireWrapVol, dd4hep::Position(0.0, 0.0, 0.0)); + + // registerVolume(lvWireWrapVol.name(), lvWireWrapVol); + // registerVolume(lvWireVol.name(), lvWireVol); + + for (int n = 0; n < w.num; n++) { + dd4hep::RotationZ iRot(w.thetaoffset + w.theta * n); + if (n % 1 == 0) w.layer.placeVolume(lvWireVol, dd4hep::Transform3D(iRot * T)); + } +} + +void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { + + // ****************************************************** + // Loading parameters + // ****************************************************** + + double halfalpha = 0.5 * dd4hep::_toDouble("CDCH:alpha"); + double inner_radius = dd4hep::_toDouble("CDCH:r0"); + double outer_radius = dd4hep::_toDouble("CDCH:rOut"); + double halflength = dd4hep::_toDouble("CDCH:zHalfLength"); + double CarbonInnerWallThick = dd4hep::_toDouble("CDCH:CarbonInnerWallThick"); + double CopperInnerWallThick = dd4hep::_toDouble("CDCH:CopperInnerWallThick"); + double GasInnerWallThick = dd4hep::_toDouble("CDCH:GasInnerWallThick"); + double Carbon1OuterWallThick = dd4hep::_toDouble("CDCH:Carbon1OuterWallThick"); + double Carbon2OuterWallThick = dd4hep::_toDouble("CDCH:Carbon2OuterWallThick"); + double CopperOuterWallThick = dd4hep::_toDouble("CDCH:CopperOuterWallThick"); + double FoamOuterWallThick = dd4hep::_toDouble("CDCH:FoamOuterWallThick"); + double GasEndcapWallThick = dd4hep::_toDouble("CDCH:GasEndcapWallThick"); + double CopperEndcapWallThick = dd4hep::_toDouble("CDCH:CopperEndcapWallThick"); + double KaptonEndcapWallThick = dd4hep::_toDouble("CDCH:KaptonEndcapWallThick"); + double CarbonEndcapWallThick = dd4hep::_toDouble("CDCH:CarbonEndcapWallThick"); + double FWireShellThickIn = dd4hep::_toDouble("CDCH:FWireShellThickIn"); + double FWireShellThickOut = dd4hep::_toDouble("CDCH:FWireShellThickOut"); + double SWireShellThickIn = dd4hep::_toDouble("CDCH:SWireShellThickIn"); + double SWireShellThickOut = dd4hep::_toDouble("CDCH:SWireShellThickOut"); + double CntFWireShellThickIn = dd4hep::_toDouble("CDCH:CntFWireShellThickIn"); + double CntFWireShellThickOut = dd4hep::_toDouble("CDCH:CntFWireShellThickOut"); + double InGWireShellThickIn = dd4hep::_toDouble("CDCH:InGWireShellThickIn"); + double InGWireShellThickOut = dd4hep::_toDouble("CDCH:InGWireShellThickOut"); + double OutGWireShellThickIn = dd4hep::_toDouble("CDCH:InGWireShellThickIn"); + double OutGWireShellThickOut = dd4hep::_toDouble("CDCH:InGWireShellThickOut"); + double secure = dd4hep::_toDouble("CDCH:secure"); + double capGasLayer = dd4hep::_toDouble("CDCH:capGasLayer"); + double extShiftFW = dd4hep::_toDouble("CDCH:extShiftFW"); + double cellDimension = dd4hep::_toDouble("CDCH:cellDimension"); + double inGuardRad = dd4hep::_toDouble("CDCH:inGuardRad"); + double outGuardRad = dd4hep::_toDouble("CDCH:outGuardRad"); + int nSDeltaWire = dd4hep::_toInt("CDCH:nSDeltaWire"); + int nSWire = dd4hep::_toInt("CDCH:nSWire"); + int nInGWire = dd4hep::_toInt("CDCH:nInGWire"); + int nOutGWire = dd4hep::_toInt("CDCH:nOutGWire"); + int nStoFWireRatio = dd4hep::_toInt("CDCH:nStoFWireRatio"); + int nVerticalFWire = dd4hep::_toInt("CDCH:nVerticalFWire"); + int nSuperLayer = dd4hep::_toInt("CDCH:nSuperLayer"); + int nRing = dd4hep::_toInt("CDCH:nRing"); + int nFieldWireShells = dd4hep::_toInt("CDCH:nFieldWireShells"); + + double epsilon = 0.0; + double theta_ring = 0.0; + double theta_ring1 = 0.0; + int nFWire = 0; + int nFWire1 = 0; + int num_wire = 0; + int nHorizontalFWire = nStoFWireRatio - nVerticalFWire; + int sign_epsilon = -1; + double phi = 0.0; + double scaleFactor = 0.0; + double dropFactor = 0.0; + double epsilonFactor = 0.0; + double delta_radius_ring = cellDimension; + double senseWireRing_radius_0 = 0.0; + double iradius = 0.0; + double idelta_radius = 0.0; + + double envelop_Inner_thickness = CarbonInnerWallThick + CopperInnerWallThick + GasInnerWallThick; + double envelop_Outer_thickness = + Carbon1OuterWallThick + Carbon2OuterWallThick + CopperOuterWallThick + FoamOuterWallThick; + double FWireDiameter = FWireShellThickIn + FWireShellThickOut; + double FWradii = 0.5 * FWireDiameter; + double CntFWireDiameter = CntFWireShellThickIn + CntFWireShellThickOut; + double CntFWradii = 0.5 * CntFWireDiameter; + double SWireDiameter = SWireShellThickIn + SWireShellThickOut; + double SWradii = 0.5 * SWireDiameter; + double inGWireDiameter = InGWireShellThickIn + InGWireShellThickOut; + double inGWradii = 0.5 * inGWireDiameter; + double fakeLayerInIWthick = -0.0001 + GasInnerWallThick; + double inner_radius_0 = inner_radius + envelop_Inner_thickness - fakeLayerInIWthick; + + double radius_ring_0 = inner_radius + envelop_Inner_thickness + FWradii + secure + capGasLayer; + double radius_ringOut_0 = radius_ring_0 - FWradii - secure; + + double drop = 0.0; + double radius_ring = 0.0; + double radius_ringIn_0 = 0.0; + double radius_ringIn = 0.0; + double radius_ringOut = 0.0; + double epsilonIn = 0.0; + double epsilonOut = 0.0; + double ringangle = 0.0; + double cellBase = 0.0; + double inscribedRadius = 0.0; + double circumscribedRadius = 0.0; + double zlength = 0.0; + double cellStaggering = 0.0; + double epsilonInGwRing = 0.0; + double epsilonOutGwRing = 0.0; + + //------------------------------------------------------------------------ + // The enlarge parameter is used to see the wires in the rendering + //------------------------------------------------------------------------ + + double enlarge = 60.; + + //------------------------------------------------------------------------ + // Build the inner, outer and endcap walls first + //------------------------------------------------------------------------ + + dd4hep::Tube Endcap_Gas(inner_radius, outer_radius, 0.5 * GasEndcapWallThick); + dd4hep::Tube Endcap_Copper(inner_radius, outer_radius, 0.5 * CopperEndcapWallThick); + dd4hep::Tube Endcap_Kapton(inner_radius, outer_radius, 0.5 * KaptonEndcapWallThick); + dd4hep::Tube Endcap_Carbon(inner_radius, outer_radius, 0.5 * CarbonEndcapWallThick); + + dd4hep::Volume lvEndcapWallGas = + dd4hep::Volume("lvEndcapWallGasVol", Endcap_Gas, description.material("GasHe_90Isob_10")); + dd4hep::Volume lvEndcapWallCopper = + dd4hep::Volume("lvEndcapWallCopperVol", Endcap_Copper, description.material("G4_Cu")); + dd4hep::Volume lvEndcapWallKapton = + dd4hep::Volume("lvEndcapWallKaptonVol", Endcap_Kapton, description.material("Kapton")); + dd4hep::Volume lvEndcapWallCarbon = + dd4hep::Volume("lvEndcapWallCarbonVol", Endcap_Carbon, description.material("CarbonFiber")); + + dd4hep::Tube InnerWall_Carbon(inner_radius, inner_radius + CarbonInnerWallThick, halflength); + dd4hep::Tube InnerWall_Copper(inner_radius + CarbonInnerWallThick, + inner_radius + CarbonInnerWallThick + CopperInnerWallThick, halflength); + dd4hep::Tube InnerWall_Gas(inner_radius + CarbonInnerWallThick + CopperInnerWallThick, + inner_radius + envelop_Inner_thickness, halflength); + + dd4hep::Volume lvInnerWallCarbon = + dd4hep::Volume("lvInnerWallCarbonVol", InnerWall_Carbon, description.material("CarbonFiber")); + dd4hep::Volume lvInnerWallCopper = + dd4hep::Volume("lvInnerWallCopperVol", InnerWall_Copper, description.material("G4_Cu")); + dd4hep::Volume lvInnerWallGas = + dd4hep::Volume("lvInnerWallGasVol", InnerWall_Gas, description.material("GasHe_90Isob_10")); + + dd4hep::Tube OuterWall_Copper(outer_radius - envelop_Outer_thickness, + outer_radius - Carbon1OuterWallThick - Carbon2OuterWallThick - FoamOuterWallThick, + halflength); + dd4hep::Tube OuterWall_Carbon1(outer_radius - Carbon1OuterWallThick - Carbon2OuterWallThick - FoamOuterWallThick, + outer_radius - Carbon2OuterWallThick - FoamOuterWallThick, halflength); + dd4hep::Tube OuterWall_Foam(outer_radius - Carbon2OuterWallThick - FoamOuterWallThick, + outer_radius - Carbon2OuterWallThick, halflength); + dd4hep::Tube OuterWall_Carbon2(outer_radius - Carbon2OuterWallThick, outer_radius, halflength); + + dd4hep::Volume lvOuterWallCarbon1 = + dd4hep::Volume("lvOuterWallCarbon1Vol", OuterWall_Carbon1, description.material("CarbonFiber")); + dd4hep::Volume lvOuterWallCarbon2 = + dd4hep::Volume("lvOuterWallCarbon2Vol", OuterWall_Carbon2, description.material("CarbonFiber")); + dd4hep::Volume lvOuterWallCopper = + dd4hep::Volume("lvOuterWallCopperVol", OuterWall_Copper, description.material("G4_Cu")); + dd4hep::Volume lvOuterWallFoam = + dd4hep::Volume("lvOuterWallFoamVol", OuterWall_Foam, description.material("GasHe_90Isob_10")); + + //------------------------------------------------------------------------ + // Now we are ready to loop over the SuperLayers and fill the gas volume! + //------------------------------------------------------------------------ + + std::vector lvLayerVol; + std::vector HypeLayer; + std::vector lvFwireVol, lvSwireVol, lvGwireVol, lvWrapVol; + + string lvName1, lvName2, lvName3, HypeName1, HypeName2, HypeName3, wirecol, gascol; + string lvFwireName, lvSwireName; + + struct wire w; + // nSuperLayer = 1; + + for (int SL = 0; SL < nSuperLayer; ++SL) { + + num_wire = nSWire + SL * nSDeltaWire; + phi = 2. * TMath::Pi() / num_wire; + nFWire = nHorizontalFWire * num_wire; + theta_ring = 2. * TMath::Pi() / nFWire; + nFWire1 = nFWire / 2; + theta_ring1 = 2.0 * theta_ring; + scaleFactor = (1.0 + TMath::Pi() / num_wire) / (1.0 - TMath::Pi() / num_wire); + dropFactor = (1.0 / cos(halfalpha) - 1.0); + epsilonFactor = sin(halfalpha) / halflength; + ringangle = -0.5 * phi; + + if (SL % 3 == 0) + gascol = "vCDCH:Gas1"; + else if ((SL + 1) % 3 == 0) + gascol = "vCDCH:Gas2"; + else if ((SL + 2) % 3 == 0) + gascol = "vCDCH:Gas3"; + + if (SL % 3 == 0) + wirecol = "vCDCH:Wire1"; + else if ((SL + 1) % 3 == 0) + wirecol = "vCDCH:Wire2"; + else if ((SL + 2) % 3 == 0) + wirecol = "vCDCH:Wire3"; + + if (SL == 0) { + + double stereoOut0 = atan(radius_ringOut_0 * (1.0 * dropFactor * epsilonFactor)); + + dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_ringOut_0 - secure, stereoOut0, halflength); + lvLayerVol.push_back(dd4hep::Volume("lvLayerInit", HypeLayer0, description.material("GasHe_90Isob_10"))); + lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); + + epsilonInGwRing = atan(inGuardRad * (1.0 + dropFactor) * epsilonFactor); + zlength = halflength; + zlength -= sin(epsilonInGwRing) * inGWradii; + zlength /= cos(epsilonInGwRing); + + w.layer = lvLayerVol.back(); + w.type = "G"; + w.num = nInGWire / 2; + w.radius = inGuardRad - inGWradii; + w.theta = theta_ring1; + w.thetaoffset = ringangle; + w.stereo = epsilonInGwRing; + w.halfalpha = halfalpha; + w.thickness = 0.5 * InGWireShellThickIn * enlarge; // half the inner thickness as radius of tube + w.halflength = zlength; + + dd4hep::Tube Gwire(0.0, w.thickness, halflength); + lvGwireVol.push_back(dd4hep::Volume("Gwire_inner", Gwire, description.material("G4_Al"))); + lvGwireVol.back().setVisAttributes(description, wirecol); + + w.volume = lvGwireVol.back(); + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, -1); + + w.radius = inGuardRad + inGWradii + extShiftFW; + w.thetaoffset = ringangle + theta_ring; + w.stereo = -1.0 * epsilonInGwRing; + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, nInGWire / 2, SL, -1); + + drop = radius_ring_0 * dropFactor; + radius_ring = radius_ring_0 + drop; + epsilon = atan(radius_ring * epsilonFactor); + radius_ringIn_0 = radius_ring_0 - FWradii - 2.0 * secure; + radius_ringIn = radius_ringIn_0 + drop; + radius_ringOut_0 = radius_ring_0 + FWradii; + radius_ringOut = radius_ringOut_0 + drop; + epsilonIn = atan(sqrt(pow(radius_ringIn, 2) - pow(radius_ringIn_0, 2)) / halflength); + epsilonOut = atan(sqrt(pow(radius_ringOut, 2) - pow(radius_ringOut_0, 2)) / halflength); + + dd4hep::Hyperboloid HypeLayer1(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, halflength); + lvLayerVol.push_back(dd4hep::Volume("lvLayer_0", HypeLayer1, description.material("GasHe_90Isob_10"))); + lvLayerVol.back().setVisAttributes(description, "vCDCH:Plastic"); + + zlength = halflength; + zlength -= sin(epsilon) * FWradii; + zlength /= cos(epsilon); + + w.layer = lvLayerVol.back(); + w.type = "F"; + w.num = nFWire1; + w.radius = radius_ringIn_0 - FWradii - extShiftFW; + w.theta = theta_ring1; + w.thetaoffset = ringangle + cellStaggering - theta_ring; + w.stereo = sign_epsilon * epsilon; + w.halfalpha = halfalpha; + w.thickness = 0.5 * FWireShellThickIn * enlarge; + w.halflength = zlength; + + lvFwireName = dd4hep::_toString(SL, "lvFwire_%d_init"); + + dd4hep::Tube Fwire(0.0, w.thickness, halflength); + lvFwireVol.push_back(dd4hep::Volume(lvFwireName, Fwire, description.material("G4_Al"))); + lvFwireVol.back().setVisAttributes(description, wirecol); + + w.volume = lvFwireVol.back(); + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, -1); + + radius_ring_0 += FWradii; + + } else { + + delta_radius_ring = 2. * TMath::Pi() * radius_ringOut_0 / (num_wire - TMath::Pi()); + } + + //------------------------------------------------------------------------ + // Starting the layer ("ring") loop. nRing=8 + //------------------------------------------------------------------------ + + for (int iring = 0; iring < nRing; iring++) { + + //------------------------------------------------------------------------ + // First define some useful names for the future + //------------------------------------------------------------------------ + + HypeName1 = dd4hep::_toString(SL, "HypeLayer1_%d") + dd4hep::_toString(iring, "_%d"); + HypeName2 = dd4hep::_toString(SL, "HypeLayer2_%d") + dd4hep::_toString(iring, "_%d"); + HypeName3 = dd4hep::_toString(SL, "HypeLayer3_%d") + dd4hep::_toString(iring, "_%d"); + lvName1 = dd4hep::_toString(SL, "lvLayer1_%d") + dd4hep::_toString(iring, "_%d"); + lvName2 = dd4hep::_toString(SL, "lvLayer2_%d") + dd4hep::_toString(iring, "_%d"); + lvName3 = dd4hep::_toString(SL, "lvLayer3_%d") + dd4hep::_toString(iring, "_%d"); + + //------------------------------------------------------------------------ + // Next, fill the geometry parameters of the layer. Each layer lies + // on top of the following one, so new ringIn = old ringOut + //------------------------------------------------------------------------ + + inscribedRadius = 0.5 * delta_radius_ring; + circumscribedRadius = inscribedRadius * sqrt(2.0); + senseWireRing_radius_0 = radius_ring_0 + inscribedRadius; + sign_epsilon *= -1; + + radius_ringIn_0 = radius_ringOut_0; + radius_ringIn = radius_ringOut; + epsilonIn = epsilonOut; + + radius_ringOut_0 = radius_ringIn_0 + FWireDiameter + 2.0 * secure; + radius_ringOut = radius_ringOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + + zlength = halflength; + + //------------------------------------------------------------------------ + // Build the hyperboloid shape and the volume of the layer. This is the + // base layer of the cell. + //------------------------------------------------------------------------ + + HypeLayer.push_back(dd4hep::Hyperboloid(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, zlength)); + lvLayerVol.push_back(dd4hep::Volume(lvName1, HypeLayer.back(), description.material("GasHe_90Isob_10"))); + lvLayerVol.back().setVisAttributes(description, gascol); + + //------------------------------------------------------------------------ + // Reduce zlength to avoid volume extrusions and check the staggering + //------------------------------------------------------------------------ + + zlength -= sin(epsilon) * FWradii; + zlength /= cos(epsilon); + + if (iring % 2 == 1) + cellStaggering = theta_ring; + else + cellStaggering = 0.0; + + //------------------------------------------------------------------------ + // Fill the field wire struct with all the relevant information to be + // passed to the PlaceWires function. This is the base of the cell. + //------------------------------------------------------------------------ + + w.layer = lvLayerVol.back(); + w.type = "F"; + w.num = nFWire1; + w.radius = radius_ringIn_0 + FWradii + extShiftFW; + w.theta = theta_ring1; + w.thetaoffset = ringangle + cellStaggering; + w.stereo = sign_epsilon * epsilon; + w.halfalpha = halfalpha; + w.thickness = 0.5 * FWireShellThickIn * enlarge; + w.halflength = zlength; + + //------------------------------------------------------------------------ + // Define the field wire name and build the field wire volume + //------------------------------------------------------------------------ + + lvFwireName = dd4hep::_toString(SL, "lvFwire_%d") + dd4hep::_toString(iring, "_%d"); + + dd4hep::Tube Fwire(0.0, w.thickness, halflength); + lvFwireVol.push_back(dd4hep::Volume(lvFwireName, Fwire, description.material("G4_Al"))); + lvFwireVol.back().setVisAttributes(description, wirecol); + + //------------------------------------------------------------------------ + // Add the field wire volume to the struct and call the magic function + //------------------------------------------------------------------------ + + w.volume = lvFwireVol.back(); + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, iring); + + //------------------------------------------------------------------------ + // Next, fill the geometry parameters of the central layer. + //------------------------------------------------------------------------ + + iradius = radius_ring_0; + radius_ring_0 += delta_radius_ring; + drop = radius_ring_0 * dropFactor; + + radius_ringIn_0 = radius_ringOut_0; + radius_ringIn = radius_ringOut; + epsilonIn = epsilonOut; + radius_ringOut_0 = radius_ring_0 - FWireDiameter - 2.0 * secure; + radius_ringOut = radius_ringOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + zlength = halflength; + + //------------------------------------------------------------------------ + // Build the hyperboloid shape and the volume of the layer. This is the + // central layer of the cell. + //------------------------------------------------------------------------ + + HypeLayer.push_back(dd4hep::Hyperboloid(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, zlength)); + lvLayerVol.push_back(dd4hep::Volume(lvName2, HypeLayer.back(), description.material("GasHe_90Isob_10"))); + lvLayerVol.back().setVisAttributes(description, gascol); + + //------------------------------------------------------------------------ + // Reduce zlength to avoid volume extrusions + //------------------------------------------------------------------------ + + zlength -= sin(epsilon) * CntFWradii; + zlength /= cos(epsilon); + + //------------------------------------------------------------------------ + // Fill the sense wire struct with all the relevant information to be + // passed to the PlaceWires function. + //------------------------------------------------------------------------ + + w.layer = lvLayerVol.back(); + w.type = "S"; + w.num = num_wire; + w.radius = senseWireRing_radius_0; + w.theta = phi; + w.thetaoffset = cellStaggering; + w.stereo = sign_epsilon * epsilon; + w.halfalpha = halfalpha; + w.thickness = 0.5 * SWireShellThickIn * enlarge; + w.halflength = zlength; + + //------------------------------------------------------------------------ + // Define the sense wire name and build the sense wire volume + //------------------------------------------------------------------------ + + lvSwireName = dd4hep::_toString(SL, "lvSwire_%d") + dd4hep::_toString(iring, "_%d"); + + dd4hep::Tube Swire(0.0, w.thickness, halflength); + lvSwireVol.push_back(dd4hep::Volume(lvSwireName, Swire, description.material("G4_W"))); + lvSwireVol.back().setVisAttributes(description, wirecol); + + //------------------------------------------------------------------------ + // Add the sense wire volume to the struct and call the magic function + //------------------------------------------------------------------------ + + w.volume = lvSwireVol.back(); + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, iring); + + //------------------------------------------------------------------------ + // Tune the radius and epsilon of the central field wires + //------------------------------------------------------------------------ + + idelta_radius = delta_radius_ring * 0.5; + iradius += idelta_radius; + epsilon = atan(iradius * (1.0 + dropFactor) * epsilonFactor); + + //------------------------------------------------------------------------ + // Fill the central field wire struct with all the relevant information + // and call the magic function. + //------------------------------------------------------------------------ + + w.layer = lvLayerVol.back(); + w.type = "F"; + w.num = num_wire; + w.radius = iradius; + w.theta = phi; + w.thetaoffset = ringangle + cellStaggering; + w.stereo = sign_epsilon * epsilon; + w.halfalpha = halfalpha; + w.thickness = 0.5 * FWireShellThickIn * enlarge; + w.halflength = zlength; + w.volume = lvFwireVol.back(); + + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, iring); + + //------------------------------------------------------------------------ + // Next, fill the geometry parameters of the upper layer. + //------------------------------------------------------------------------ + + radius_ringIn_0 = radius_ringOut_0; + radius_ringIn = radius_ringOut; + epsilonIn = epsilonOut; + radius_ringOut_0 = radius_ringIn_0 + FWireDiameter + 2.0 * secure; + radius_ringOut = radius_ringOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + zlength = halflength; + + //------------------------------------------------------------------------ + // Build the hyperboloid shape and the volume of the layer. This is the + // central layer of the cell. + //------------------------------------------------------------------------ + + HypeLayer.push_back(dd4hep::Hyperboloid(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, zlength)); + lvLayerVol.push_back(dd4hep::Volume(lvName3, HypeLayer.back(), description.material("GasHe_90Isob_10"))); + lvLayerVol.back().setVisAttributes(description, gascol); + + //------------------------------------------------------------------------ + // Reduce zlength to avoid volume extrusions + //------------------------------------------------------------------------ + + zlength -= sin(epsilon) * FWradii; + zlength /= cos(epsilon); + + //------------------------------------------------------------------------ + // Fill the field wire struct with all the relevant information and + // call the magic function. This is the top of the cell. + //------------------------------------------------------------------------ + + w.layer = lvLayerVol.back(); + w.type = "F"; + w.num = nFWire1; + w.radius = radius_ringIn_0 - FWradii - extShiftFW; + w.theta = theta_ring1; + w.thetaoffset = ringangle + cellStaggering; + w.stereo = sign_epsilon * epsilon; + w.halfalpha = halfalpha; + w.thickness = 0.5 * FWireShellThickIn * enlarge; + w.halflength = zlength; + w.volume = lvFwireVol.back(); + + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, iring); + + //------------------------------------------------------------------------ + // Scale the delta radius of the ring for next iteration + //------------------------------------------------------------------------ + + delta_radius_ring *= scaleFactor; + } + + if (SL == (nSuperLayer - 1)) { + + radius_ringIn_0 = radius_ringOut_0; + radius_ringIn = radius_ringOut; + epsilonIn = epsilonOut; + radius_ringOut_0 = radius_ring_0 + FWireDiameter + 2.0 * secure; + radius_ringOut = radius_ringOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + + dd4hep::Hyperboloid HypeLayerOut(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, halflength); + lvLayerVol.push_back(dd4hep::Volume("lvLayerOut", HypeLayerOut, description.material("GasHe_90Isob_10"))); + lvLayerVol.back().setVisAttributes(description, "vCDCH:Plastic"); + + zlength = halflength; + zlength -= sin(epsilon) * FWradii; + zlength /= cos(epsilon); + + w.layer = lvLayerVol.back(); + w.type = "F"; + w.num = nFWire1; + w.radius = radius_ringIn_0 + FWradii + extShiftFW; + w.theta = theta_ring1; + w.thetaoffset = ringangle + cellStaggering + theta_ring; + w.stereo = -1. * sign_epsilon * epsilon; + w.halfalpha = halfalpha; + w.thickness = 0.5 * FWireShellThickIn * enlarge; + w.halflength = zlength; + + lvFwireName = dd4hep::_toString(SL, "lvFwire_%d_out"); + + dd4hep::Tube Fwire(0.0, w.thickness, halflength); + lvFwireVol.push_back(dd4hep::Volume(lvFwireName, Fwire, description.material("G4_Al"))); + lvFwireVol.back().setVisAttributes(description, wirecol); + + w.volume = lvFwireVol.back(); + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, -1); + + //------------------------------------------------------------------------ + // Start placing the outer layer of guard wires + //------------------------------------------------------------------------ + + radius_ringIn_0 = radius_ringOut_0; + radius_ringIn = radius_ringOut; + epsilonIn = epsilonOut; + radius_ringOut_0 = radius_ring_0 + FWireDiameter + 2.0 * secure; + radius_ringOut = radius_ringOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + + dd4hep::Hyperboloid HypeLayerOutG(radius_ringIn_0, epsilonOut, outer_radius - envelop_Outer_thickness - 0.0001, + 0.0, halflength); + lvLayerVol.push_back(dd4hep::Volume("lvLayerOutG", HypeLayerOutG, description.material("GasHe_90Isob_10"))); + lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); + + epsilonOutGwRing = atan(outGuardRad * (1.0 + dropFactor) * epsilonFactor); + zlength = halflength; + zlength -= sin(epsilonOutGwRing) * inGWradii; + zlength /= cos(epsilonOutGwRing); + + w.layer = lvLayerVol.back(); + w.type = "G"; + w.num = nOutGWire / 2; + w.radius = outGuardRad - inGWradii; + w.theta = theta_ring1; + w.thetaoffset = ringangle; + w.stereo = epsilonOutGwRing; + w.halfalpha = halfalpha; + w.thickness = 0.5 * OutGWireShellThickIn * enlarge; + w.halflength = zlength; + + dd4hep::Tube Gwire(0.0, w.thickness, halflength); + lvGwireVol.push_back(dd4hep::Volume("Gwire_outer", Gwire, description.material("G4_Al"))); + lvGwireVol.back().setVisAttributes(description, wirecol); + + w.volume = lvGwireVol.back(); + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, -1); + + w.radius = outGuardRad + inGWradii + extShiftFW; + w.thetaoffset = ringangle + theta_ring; + w.stereo = -1.0 * epsilonOutGwRing; + CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, nOutGWire / 2, SL, -1); + } + } + + dd4hep::PlacedVolume pv; + dd4hep::DetElement CDCHDetector(parent, "Ecal_DP", parent.id()); + + Int_t sizeLayer = lvLayerVol.size(); + + for (Int_t i = 0; i < sizeLayer; i++) { + registerVolume(lvLayerVol.at(i).name(), lvLayerVol.at(i)); + cout << "Placing Volume: " << lvLayerVol.at(i).name() << endl; + pv = parentVol.placeVolume(volume(lvLayerVol.at(i).name())); + CDCHDetector.setPlacement(pv); + } + + double PosEndcapGas = halflength + 0.5 * GasEndcapWallThick; + double PosEndcapCopper = halflength + GasEndcapWallThick + 0.5 * CopperEndcapWallThick; + double PosEndcapKapton = halflength + GasEndcapWallThick + CopperEndcapWallThick + 0.5 * KaptonEndcapWallThick; + double PosEndcapCarbon = + halflength + GasEndcapWallThick + CopperEndcapWallThick + KaptonEndcapWallThick + 0.5 * CarbonEndcapWallThick; + + parentVol.placeVolume(lvInnerWallCarbon); + parentVol.placeVolume(lvInnerWallCopper); + parentVol.placeVolume(lvInnerWallGas); + parentVol.placeVolume(lvOuterWallCarbon1); + parentVol.placeVolume(lvOuterWallCarbon2); + parentVol.placeVolume(lvOuterWallCopper); + parentVol.placeVolume(lvOuterWallFoam); + parentVol.placeVolume(lvEndcapWallGas, dd4hep::Position(0., 0., PosEndcapGas)); + parentVol.placeVolume(lvEndcapWallCopper, dd4hep::Position(0., 0., PosEndcapCopper)); + parentVol.placeVolume(lvEndcapWallKapton, dd4hep::Position(0., 0., PosEndcapKapton)); + parentVol.placeVolume(lvEndcapWallCarbon, dd4hep::Position(0., 0., PosEndcapCarbon)); + parentVol.placeVolume(lvEndcapWallGas, dd4hep::Position(0., 0., -PosEndcapGas)); + parentVol.placeVolume(lvEndcapWallCopper, dd4hep::Position(0., 0., -PosEndcapCopper)); + parentVol.placeVolume(lvEndcapWallKapton, dd4hep::Position(0., 0., -PosEndcapKapton)); + parentVol.placeVolume(lvEndcapWallCarbon, dd4hep::Position(0., 0., -PosEndcapCarbon)); +} + +} // namespace + +static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4hep::SensitiveDetector sens_det) { + + xml_det_t x_det = e; + CDCHBuild builder(description, x_det, sens_det); + string det_name = x_det.nameStr(); + + dd4hep::printout(dd4hep::DEBUG, "CreateCDCH", "Detector name: %s with ID: %s", det_name.c_str(), x_det.id()); + + DetElement CDCH_det = builder.detector; // ( det_name, x_det.id() ); + dd4hep::Box CDCH_box("5000/2", "5000/2", "5000/2"); + + Volume envelope("lvCDCH", CDCH_box, description.air()); + envelope.setVisAttributes(description, "vCDCH:Air"); + PlacedVolume pv; + + dd4hep::printout(dd4hep::DEBUG, "CreateCDCH", "MotherVolume is: %s", envelope.name()); + sens_det.setType("tracker"); + + builder.buildVolumes(e); + builder.placeDaughters(CDCH_det, envelope, e); + + // ****************************************************** + // Build CDCH cable + // ****************************************************** + + builder.build_layer(CDCH_det, envelope); + + // ****************************************************** + // Build CDCH cell and beam plug + // ****************************************************** + + // builder.build_cell(); + // builder.build_beamplug(); + + // ****************************************************** + // Assemble CDCH + // ****************************************************** + + // builder.build_CDCH( Ecal_det, envelope ); + + // ****************************************************** + // Place the CDCH in the world + // ****************************************************** + + pv = builder.placeDetector(envelope); + pv.addPhysVolID("system", x_det.id()); + + return CDCH_det; +} + +DECLARE_DETELEMENT(DriftChamber_o1_v01, create_element) From 4b5bda0fbc766834228a5df90b352d7322ca3a3e Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 20 Jul 2023 12:57:59 +0200 Subject: [PATCH 02/20] [DriftChamber] First working version with cell volume defined --- .../DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 568 +++++++++++------- 1 file changed, 363 insertions(+), 205 deletions(-) diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index efab0c60..9227473b 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -1,35 +1,34 @@ -/*****************************************************************************\ -* DD4hep geometry code for the central drift chamber of the IDEA detector * -* Author: Lorenzo Capriotti * -\*****************************************************************************/ +/***************************************************************************************\ +* DD4hep geometry code for the central drift chamber of the IDEA detector * +* Author: Lorenzo Capriotti, Modified by Brieuc Francois to have sensitive cell volumes * +\***************************************************************************************/ #include "DD4hep/DetFactoryHelper.h" #include "DD4hep/Printout.h" #include "DD4hep/detail/DetectorInterna.h" #include "TClass.h" #include "TMath.h" #include "XML/Utilities.h" -#include #include #include +#include using namespace std; using namespace dd4hep; struct wire - { - - dd4hep::Volume layer; + dd4hep::Volume mother_volume; string type; int num; double radius; - double theta; - double thetaoffset; + double phi; + double phioffset; double stereo; double halfalpha; double thickness; double halflength; dd4hep::Volume volume; + string name; }; namespace { @@ -40,8 +39,9 @@ struct CDCHBuild : public dd4hep::xml::tools::VolumeBuilder { CDCHBuild(dd4hep::Detector& description, xml_elt_t e, dd4hep::SensitiveDetector sens); double diff_of_squares(double a, double b); - void PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset, int SL, int iring, int wirenum); - void build_layer(DetElement parent, Volume parentVol); + void apply_wire_coating(struct wire& w, double outwrap, double halflength, string material); + void PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset, int SL, int iring); + void build_layer(DetElement parent, Volume parentVol, dd4hep::SensitiveDetector sens); }; // ****************************************************** @@ -57,12 +57,22 @@ double CDCHBuild::diff_of_squares(double a, double b) { return diff; } +void CDCHBuild::apply_wire_coating(struct wire& w, double outwrap, double halflength, string material = "G4_Au"){ + dd4hep::Tube WrapTube(w.thickness, w.thickness + 0.5 * outwrap, halflength); + dd4hep::Volume lvWireWrapVol(w.name + "_coating", WrapTube, description.material(material)); + dd4hep::Tube TotalWire(0.0, w.thickness + 0.5 * outwrap, halflength); + dd4hep::Volume lvWireVol(w.name + "_totalWire", TotalWire, description.material("Air")); + lvWireVol.placeVolume(w.volume, dd4hep::Position(0.0, 0.0, 0.0)); + lvWireVol.placeVolume(lvWireWrapVol, dd4hep::Position(0.0, 0.0, 0.0)); + w.volume = lvWireVol; +} + +// deprecated function, only use it for the wires before and after the sensitive zone (mainly guard wires) void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset = 0, int SL = 999, - int iring = 999, int wirenum = -1) { + int iring = 999) { dd4hep::RotationZYX rot(0., 0., w.stereo); dd4hep::RotationX rot_stereo(w.stereo); - dd4hep::Position pos(w.radius, 0., 0.); dd4hep::Translation3D transl(w.radius, 0., 0.); dd4hep::Transform3D T(transl * rot_stereo); @@ -76,7 +86,7 @@ void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, in wirewrapname += "_stereo"; wirewrapname += std::to_string(w.stereo); - cout << "wirewrapname: " << wirewrapname << endl; + //cout << "wirewrapname: " << wirewrapname << endl; string wirename = "lvWire_SL"; wirename += std::to_string(SL); @@ -87,26 +97,22 @@ void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, in wirename += "_stereo"; wirename += std::to_string(w.stereo); - dd4hep::Tube WrapTube(w.thickness, w.thickness + 0.5 * outwrap, halflength); - dd4hep::Volume lvWireWrapVol(wirewrapname, WrapTube, description.material("G4_Au")); - - dd4hep::Tube TotalWire(0.0, w.thickness + 0.5 * outwrap, halflength); - dd4hep::Volume lvWireVol(wirename, TotalWire, description.material("Air")); - - lvWireVol.placeVolume(w.volume, dd4hep::Position(0.0, 0.0, 0.0)); - lvWireVol.placeVolume(lvWireWrapVol, dd4hep::Position(0.0, 0.0, 0.0)); + //apply_wire_coating(w, outwrap, halflength); // registerVolume(lvWireWrapVol.name(), lvWireWrapVol); // registerVolume(lvWireVol.name(), lvWireVol); + // repeat the placement of wires over phi for (int n = 0; n < w.num; n++) { - dd4hep::RotationZ iRot(w.thetaoffset + w.theta * n); - if (n % 1 == 0) w.layer.placeVolume(lvWireVol, dd4hep::Transform3D(iRot * T)); + dd4hep::RotationZ iRot(w.phioffset + w.phi * n); + if (n % 1 == 0) w.mother_volume.placeVolume(w.volume, dd4hep::Transform3D(iRot * T)); } } -void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { +void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::SensitiveDetector sens_det) { + //dd4hep::PlacedVolume pv; + dd4hep::DetElement CDCHDetector(parent, "CDCH", parent.id()); // ****************************************************** // Loading parameters // ****************************************************** @@ -151,10 +157,11 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { int nSuperLayer = dd4hep::_toInt("CDCH:nSuperLayer"); int nRing = dd4hep::_toInt("CDCH:nRing"); int nFieldWireShells = dd4hep::_toInt("CDCH:nFieldWireShells"); + //bool setWireSensitive = true; // FIXME: add the possibility to have wires sensitive (parameter in the xml) which could be useful for detailed chamber behavior studies, current attempt never lead to a hit in the wire, even with enlarged wires... double epsilon = 0.0; - double theta_ring = 0.0; - double theta_ring1 = 0.0; + double phi_ring = 0.0; + double phi_ring1 = 0.0; int nFWire = 0; int nFWire1 = 0; int num_wire = 0; @@ -201,6 +208,8 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { double cellStaggering = 0.0; double epsilonInGwRing = 0.0; double epsilonOutGwRing = 0.0; + double radius_ringIn_whole_cell = 0.0; + double epsilonIn_whole_cell = 0.0; //------------------------------------------------------------------------ // The enlarge parameter is used to see the wires in the rendering @@ -257,18 +266,18 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { dd4hep::Volume lvOuterWallFoam = dd4hep::Volume("lvOuterWallFoamVol", OuterWall_Foam, description.material("GasHe_90Isob_10")); + //------------------------------------------------------------------------ // Now we are ready to loop over the SuperLayers and fill the gas volume! //------------------------------------------------------------------------ std::vector lvLayerVol; - std::vector HypeLayer; - std::vector lvFwireVol, lvSwireVol, lvGwireVol, lvWrapVol; + std::vector lvFwireVol, lvGwireVol; - string lvName1, lvName2, lvName3, HypeName1, HypeName2, HypeName3, wirecol, gascol; + string wirecol, gascol, wholeHyperboloidVolumeName; string lvFwireName, lvSwireName; - struct wire w; + struct wire guard_wires{}, field_wires_bottom{}, field_wires_center{}, field_wires_top{}, sense_wires{}; // nSuperLayer = 1; for (int SL = 0; SL < nSuperLayer; ++SL) { @@ -276,14 +285,17 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { num_wire = nSWire + SL * nSDeltaWire; phi = 2. * TMath::Pi() / num_wire; nFWire = nHorizontalFWire * num_wire; - theta_ring = 2. * TMath::Pi() / nFWire; + phi_ring = 2. * TMath::Pi() / nFWire; nFWire1 = nFWire / 2; - theta_ring1 = 2.0 * theta_ring; + if (ceilf(nFWire1) != nFWire1) + throw std::runtime_error("Error: Failed to build CDCH. Please make sure that '(nStoFWireRatio - nVerticalFWire) * (nSWire + SuperLayerIndex * nSDeltaWire)' is always an even number"); + phi_ring1 = 2.0 * phi_ring; scaleFactor = (1.0 + TMath::Pi() / num_wire) / (1.0 - TMath::Pi() / num_wire); dropFactor = (1.0 / cos(halfalpha) - 1.0); epsilonFactor = sin(halfalpha) / halflength; ringangle = -0.5 * phi; + gascol = "vCDCH:Gas1"; if (SL % 3 == 0) gascol = "vCDCH:Gas1"; else if ((SL + 1) % 3 == 0) @@ -298,41 +310,123 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { else if ((SL + 2) % 3 == 0) wirecol = "vCDCH:Wire3"; - if (SL == 0) { + if (SL == 0) {// SL = 0 is special due to the guard wires and the first field wires that lie outside of the sensitive volume + // deal with the first guard layer double stereoOut0 = atan(radius_ringOut_0 * (1.0 * dropFactor * epsilonFactor)); + + + //dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_ringOut_0 - secure, stereoOut0, halflength); + //lvLayerVol.push_back(dd4hep::Volume("lvLayerInit", HypeLayer0, description.material("GasHe_90Isob_10"))); + //lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); + + //epsilonInGwRing = atan(inGuardRad * (1.0 + dropFactor) * epsilonFactor); + //zlength = halflength; + //zlength -= sin(epsilonInGwRing) * inGWradii; + //zlength /= cos(epsilonInGwRing); + + //guard_wires.mother_volume = lvLayerVol.back(); + //guard_wires.type = string("G"); + //guard_wires.num = nInGWire / 2; + //guard_wires.radius = inGuardRad - inGWradii; + //guard_wires.phi = phi_ring1; + //guard_wires.phioffset = ringangle; + //guard_wires.stereo = epsilonInGwRing; + //guard_wires.halfalpha = halfalpha; + //guard_wires.thickness = 0.5 * InGWireShellThickIn * enlarge; // half the inner thickness as radius of tube + //guard_wires.halflength = zlength; + + //dd4hep::Tube Gwire(0.0, guard_wires.thickness, halflength); + //lvGwireVol.push_back(dd4hep::Volume("Gwire_inner", Gwire, description.material("G4_Al"))); + //lvGwireVol.back().setVisAttributes(description, wirecol); + + //guard_wires.volume = lvGwireVol.back(); + ////CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, 0, SL, -1); + + + cout << "********************************" << endl; + + + dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_ringOut_0 - secure, stereoOut0, halflength); - lvLayerVol.push_back(dd4hep::Volume("lvLayerInit", HypeLayer0, description.material("GasHe_90Isob_10"))); - lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); + dd4hep::Volume inner_guard_layer_volume("hyperboloid_inner_guard_layer", HypeLayer0, description.material("GasHe_90Isob_10")); + int count = 0; + count += 1; + std::cout << count << std::endl; + dd4hep::PlacedVolume inner_guard_layer_placedVolume = parentVol.placeVolume(inner_guard_layer_volume); + CDCHDetector.setPlacement(inner_guard_layer_placedVolume); + + //lvLayerVol.push_back(dd4hep::Volume("lvLayerInit", HypeLayer0, description.material("GasHe_90Isob_10"))); + //lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); + epsilonInGwRing = atan(inGuardRad * (1.0 + dropFactor) * epsilonFactor); zlength = halflength; zlength -= sin(epsilonInGwRing) * inGWradii; zlength /= cos(epsilonInGwRing); - w.layer = lvLayerVol.back(); - w.type = "G"; - w.num = nInGWire / 2; - w.radius = inGuardRad - inGWradii; - w.theta = theta_ring1; - w.thetaoffset = ringangle; - w.stereo = epsilonInGwRing; - w.halfalpha = halfalpha; - w.thickness = 0.5 * InGWireShellThickIn * enlarge; // half the inner thickness as radius of tube - w.halflength = zlength; - - dd4hep::Tube Gwire(0.0, w.thickness, halflength); + count += 1; + std::cout << count << std::endl; + + //guard_wires.mother_volume = lvLayerVol.back(); + guard_wires.mother_volume = inner_guard_layer_volume; + count += 1; + std::cout << count << std::endl; + guard_wires.type = string("G"); + guard_wires.num = nInGWire / 2; + guard_wires.radius = inGuardRad - inGWradii; + guard_wires.phi = phi_ring1; + guard_wires.phioffset = ringangle; + count += 1; + std::cout << count << std::endl; + guard_wires.stereo = epsilonInGwRing; + guard_wires.halfalpha = halfalpha; + guard_wires.thickness = 0.5 * InGWireShellThickIn * enlarge; // half the inner thickness as radius of tube + guard_wires.halflength = zlength; + count += 1; + std::cout << count << std::endl; + //guard_wires.name = "lvWire_SL" + std::to_string(SL) + "_ring0_type" + guard_wires.type + "_stereo" + std::to_string(guard_wires.stereo); + //guard_wires.name = string("InnerGuardWire") + dd4hep::_toString(guard_wires.stereo, "_stereo%f"); + guard_wires.name = string("blo"); + count += 1; + std::cout << count << std::endl; + dd4hep::Tube Gwire(0.0, guard_wires.thickness, halflength); + count += 1; + std::cout << count << std::endl; lvGwireVol.push_back(dd4hep::Volume("Gwire_inner", Gwire, description.material("G4_Al"))); lvGwireVol.back().setVisAttributes(description, wirecol); - - w.volume = lvGwireVol.back(); - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, -1); - - w.radius = inGuardRad + inGWradii + extShiftFW; - w.thetaoffset = ringangle + theta_ring; - w.stereo = -1.0 * epsilonInGwRing; - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, nInGWire / 2, SL, -1); + guard_wires.volume = lvGwireVol.back(); + count += 1; + std::cout << count << std::endl; + apply_wire_coating(guard_wires, InGWireShellThickIn, halflength); + // Radial translation + dd4hep::Translation3D radial_translation_guard_wire(guard_wires.radius, 0., 0.); + // stereo rotation + dd4hep::RotationX rot_stereo_guard_wire(guard_wires.stereo); + //dd4hep::PlacedVolume inner_guard_wire_placedvolume; + count += 1; + std::cout << count << std::endl; + for (int phi_index = 0; phi_index < guard_wires.num; phi_index++) { + dd4hep::RotationZ iRot(guard_wires.phioffset + guard_wires.phi * phi_index); + //dd4hep::Transform3D total_transformation(iRot * radial_translation_guard_wire * rot_stereo_guard_wire); + //dd4hep::Transform3D total_transformation(iRot * radial_translation_guard_wire * rot_stereo_guard_wire); + //inner_guard_wire_placedvolume = inner_guard_layer_volume.placeVolume(guard_wires.volume, total_transformation); + //inner_guard_wire_placedvolume = inner_guard_layer_volume.placeVolume(guard_wires.volume, dd4hep::Transform3D(iRot * radial_translation_guard_wire * rot_stereo_guard_wire)); + dd4hep::PlacedVolume inner_guard_wire_placedvolume = inner_guard_layer_volume.placeVolume(guard_wires.volume, dd4hep::Transform3D(iRot * radial_translation_guard_wire)); + //if(setWireSensitive) + // inner_guard_wire_placedvolume.addPhysVolID("phi", phi_index).addPhysVolID("hitorigin", 3).addPhysVolID("stereo", guard_wires.stereo > 0 ? 0 : 1).addPhysVolID("layerInCell", 0); + } + count += 1; + std::cout << count << std::endl; + + guard_wires.radius = inGuardRad + inGWradii + extShiftFW; + guard_wires.phioffset = ringangle + phi_ring; + guard_wires.stereo = -1.0 * epsilonInGwRing; + //guard_wires.name = "lvWire_SL" + std::to_string(SL) + "_ring0_type" + guard_wires.type + "_stereo" + std::to_string(guard_wires.stereo); + //guard_wires.name = string("InnerGuardWire") + dd4hep::_toString(guard_wires.stereo, "_stereo%f"); + guard_wires.name = string("bla"); + //CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, nInGWire / 2, SL, -1); drop = radius_ring_0 * dropFactor; radius_ring = radius_ring_0 + drop; @@ -352,25 +446,27 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { zlength -= sin(epsilon) * FWradii; zlength /= cos(epsilon); - w.layer = lvLayerVol.back(); - w.type = "F"; - w.num = nFWire1; - w.radius = radius_ringIn_0 - FWradii - extShiftFW; - w.theta = theta_ring1; - w.thetaoffset = ringangle + cellStaggering - theta_ring; - w.stereo = sign_epsilon * epsilon; - w.halfalpha = halfalpha; - w.thickness = 0.5 * FWireShellThickIn * enlarge; - w.halflength = zlength; + field_wires_top.mother_volume = lvLayerVol.back(); + field_wires_top.type = string("F"); + field_wires_top.num = nFWire1; + field_wires_top.radius = radius_ringIn_0 - FWradii - extShiftFW; + field_wires_top.phi = phi_ring1; + field_wires_top.phioffset = ringangle + cellStaggering - phi_ring; + field_wires_top.stereo = sign_epsilon * epsilon; + field_wires_top.halfalpha = halfalpha; + field_wires_top.thickness = 0.5 * FWireShellThickIn * enlarge; + field_wires_top.halflength = zlength; + //field_wires_top.name = dd4hep::_toString(SL, "lvWire_SL%d") + dd4hep::_toString(-1, "_ring%d") + string("_type") + field_wires_top.type + dd4hep::_toString(field_wires_top.stereo, "_stereo%f_top"); + field_wires_top.name = string("blu"); lvFwireName = dd4hep::_toString(SL, "lvFwire_%d_init"); - dd4hep::Tube Fwire(0.0, w.thickness, halflength); + dd4hep::Tube Fwire(0.0, field_wires_top.thickness, halflength); lvFwireVol.push_back(dd4hep::Volume(lvFwireName, Fwire, description.material("G4_Al"))); lvFwireVol.back().setVisAttributes(description, wirecol); - w.volume = lvFwireVol.back(); - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, -1); + //field_wires_top.volume = lvFwireVol.back(); + ////CDCHBuild::PlaceWires(field_wires_top, FWireShellThickOut, halflength, 0, SL, -1); radius_ring_0 += FWradii; @@ -384,20 +480,8 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { //------------------------------------------------------------------------ for (int iring = 0; iring < nRing; iring++) { - - //------------------------------------------------------------------------ - // First define some useful names for the future - //------------------------------------------------------------------------ - - HypeName1 = dd4hep::_toString(SL, "HypeLayer1_%d") + dd4hep::_toString(iring, "_%d"); - HypeName2 = dd4hep::_toString(SL, "HypeLayer2_%d") + dd4hep::_toString(iring, "_%d"); - HypeName3 = dd4hep::_toString(SL, "HypeLayer3_%d") + dd4hep::_toString(iring, "_%d"); - lvName1 = dd4hep::_toString(SL, "lvLayer1_%d") + dd4hep::_toString(iring, "_%d"); - lvName2 = dd4hep::_toString(SL, "lvLayer2_%d") + dd4hep::_toString(iring, "_%d"); - lvName3 = dd4hep::_toString(SL, "lvLayer3_%d") + dd4hep::_toString(iring, "_%d"); - //------------------------------------------------------------------------ - // Next, fill the geometry parameters of the layer. Each layer lies + // Fill the geometry parameters of the layer. Each layer lies // on top of the following one, so new ringIn = old ringOut //------------------------------------------------------------------------ @@ -416,14 +500,9 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { zlength = halflength; - //------------------------------------------------------------------------ - // Build the hyperboloid shape and the volume of the layer. This is the - // base layer of the cell. - //------------------------------------------------------------------------ - - HypeLayer.push_back(dd4hep::Hyperboloid(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, zlength)); - lvLayerVol.push_back(dd4hep::Volume(lvName1, HypeLayer.back(), description.material("GasHe_90Isob_10"))); - lvLayerVol.back().setVisAttributes(description, gascol); + // save bottom layer inner radius and epsilon before they are modified to build the whole layer hyperboloid volume + radius_ringIn_whole_cell = radius_ringIn_0; + epsilonIn_whole_cell = epsilonIn; //------------------------------------------------------------------------ // Reduce zlength to avoid volume extrusions and check the staggering @@ -433,25 +512,26 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { zlength /= cos(epsilon); if (iring % 2 == 1) - cellStaggering = theta_ring; + cellStaggering = phi_ring; else cellStaggering = 0.0; //------------------------------------------------------------------------ // Fill the field wire struct with all the relevant information to be - // passed to the PlaceWires function. This is the base of the cell. + // passed to the PlaceWires function. This is the bottom of the cell. //------------------------------------------------------------------------ - w.layer = lvLayerVol.back(); - w.type = "F"; - w.num = nFWire1; - w.radius = radius_ringIn_0 + FWradii + extShiftFW; - w.theta = theta_ring1; - w.thetaoffset = ringangle + cellStaggering; - w.stereo = sign_epsilon * epsilon; - w.halfalpha = halfalpha; - w.thickness = 0.5 * FWireShellThickIn * enlarge; - w.halflength = zlength; + field_wires_bottom.type = string("F"); + field_wires_bottom.num = nFWire1; + field_wires_bottom.radius = radius_ringIn_0 + FWradii + extShiftFW; + field_wires_bottom.phi = phi_ring1; + field_wires_bottom.phioffset = ringangle + cellStaggering; + field_wires_bottom.stereo = sign_epsilon * epsilon; + field_wires_bottom.halfalpha = halfalpha; + field_wires_bottom.thickness = 0.5 * FWireShellThickIn * enlarge; + field_wires_bottom.halflength = zlength; + field_wires_bottom.name = dd4hep::_toString(SL, "lvWire_SL%d") + dd4hep::_toString(iring, "_ring%d") + string("_type") + field_wires_bottom.type + dd4hep::_toString(field_wires_bottom.stereo, "_stereo%f_bottom"); + //field_wires_bottom.name = "lvWire_SL" + std::to_string(SL) + "_ring" + std::to_string(iring) + "_type" + field_wires_bottom.type + "_stereo" + std::to_string(field_wires_bottom.stereo) + "_bottom"; //------------------------------------------------------------------------ // Define the field wire name and build the field wire volume @@ -459,7 +539,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { lvFwireName = dd4hep::_toString(SL, "lvFwire_%d") + dd4hep::_toString(iring, "_%d"); - dd4hep::Tube Fwire(0.0, w.thickness, halflength); + dd4hep::Tube Fwire(0.0, field_wires_bottom.thickness, halflength); lvFwireVol.push_back(dd4hep::Volume(lvFwireName, Fwire, description.material("G4_Al"))); lvFwireVol.back().setVisAttributes(description, wirecol); @@ -467,8 +547,8 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { // Add the field wire volume to the struct and call the magic function //------------------------------------------------------------------------ - w.volume = lvFwireVol.back(); - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, iring); + field_wires_bottom.volume = lvFwireVol.back(); + apply_wire_coating(field_wires_bottom, FWireShellThickOut, halflength); //------------------------------------------------------------------------ // Next, fill the geometry parameters of the central layer. @@ -486,15 +566,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); zlength = halflength; - //------------------------------------------------------------------------ - // Build the hyperboloid shape and the volume of the layer. This is the - // central layer of the cell. - //------------------------------------------------------------------------ - - HypeLayer.push_back(dd4hep::Hyperboloid(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, zlength)); - lvLayerVol.push_back(dd4hep::Volume(lvName2, HypeLayer.back(), description.material("GasHe_90Isob_10"))); - lvLayerVol.back().setVisAttributes(description, gascol); - //------------------------------------------------------------------------ // Reduce zlength to avoid volume extrusions //------------------------------------------------------------------------ @@ -507,16 +578,17 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { // passed to the PlaceWires function. //------------------------------------------------------------------------ - w.layer = lvLayerVol.back(); - w.type = "S"; - w.num = num_wire; - w.radius = senseWireRing_radius_0; - w.theta = phi; - w.thetaoffset = cellStaggering; - w.stereo = sign_epsilon * epsilon; - w.halfalpha = halfalpha; - w.thickness = 0.5 * SWireShellThickIn * enlarge; - w.halflength = zlength; + sense_wires.type = string("S"); + sense_wires.num = num_wire; + sense_wires.radius = senseWireRing_radius_0; + sense_wires.phi = phi; + sense_wires.phioffset = cellStaggering; + sense_wires.stereo = sign_epsilon * epsilon; + sense_wires.halfalpha = halfalpha; + sense_wires.thickness = 0.5 * SWireShellThickIn * enlarge; + sense_wires.halflength = zlength; + sense_wires.name = dd4hep::_toString(SL, "lvWire_SL%d") + dd4hep::_toString(iring, "_ring%d") + string("_type") + sense_wires.type + dd4hep::_toString(sense_wires.stereo, "_stereo%f"); + //sense_wires.name = "lvWire_SL" + std::to_string(SL) + "_ring" + std::to_string(iring) + "_type" + sense_wires.type + "_stereo" + std::to_string(sense_wires.stereo); //------------------------------------------------------------------------ // Define the sense wire name and build the sense wire volume @@ -524,16 +596,11 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { lvSwireName = dd4hep::_toString(SL, "lvSwire_%d") + dd4hep::_toString(iring, "_%d"); - dd4hep::Tube Swire(0.0, w.thickness, halflength); - lvSwireVol.push_back(dd4hep::Volume(lvSwireName, Swire, description.material("G4_W"))); - lvSwireVol.back().setVisAttributes(description, wirecol); - - //------------------------------------------------------------------------ - // Add the sense wire volume to the struct and call the magic function - //------------------------------------------------------------------------ - - w.volume = lvSwireVol.back(); - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, iring); + dd4hep::Tube Swire(0.0, sense_wires.thickness, halflength); + dd4hep::Volume lvSwireVol(lvSwireName, Swire, description.material("G4_W")); + lvSwireVol.setVisAttributes(description, wirecol); + sense_wires.volume = lvSwireVol; + apply_wire_coating(sense_wires, SWireShellThickOut, halflength); //------------------------------------------------------------------------ // Tune the radius and epsilon of the central field wires @@ -548,19 +615,20 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { // and call the magic function. //------------------------------------------------------------------------ - w.layer = lvLayerVol.back(); - w.type = "F"; - w.num = num_wire; - w.radius = iradius; - w.theta = phi; - w.thetaoffset = ringangle + cellStaggering; - w.stereo = sign_epsilon * epsilon; - w.halfalpha = halfalpha; - w.thickness = 0.5 * FWireShellThickIn * enlarge; - w.halflength = zlength; - w.volume = lvFwireVol.back(); + field_wires_center.type = string("F"); + field_wires_center.num = num_wire; + field_wires_center.radius = iradius; + field_wires_center.phi = phi; + field_wires_center.phioffset = ringangle + cellStaggering; + field_wires_center.stereo = sign_epsilon * epsilon; + field_wires_center.halfalpha = halfalpha; + field_wires_center.thickness = 0.5 * FWireShellThickIn * enlarge; + field_wires_center.halflength = zlength; + field_wires_center.volume = lvFwireVol.back(); + field_wires_center.name = dd4hep::_toString(SL, "lvWire_SL%d") + dd4hep::_toString(iring, "_ring%d") + string("_type") + field_wires_center.type + dd4hep::_toString(field_wires_center.stereo, "_stereo%f_center"); + //field_wires_center.name = "lvWire_SL" + std::to_string(SL) + "_ring" + std::to_string(iring) + "_type" + field_wires_center.type + "_stereo" + std::to_string(field_wires_center.stereo) + "_middle"; + apply_wire_coating(field_wires_center, FWireShellThickOut, halflength); - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, iring); //------------------------------------------------------------------------ // Next, fill the geometry parameters of the upper layer. @@ -579,9 +647,23 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { // central layer of the cell. //------------------------------------------------------------------------ - HypeLayer.push_back(dd4hep::Hyperboloid(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, zlength)); - lvLayerVol.push_back(dd4hep::Volume(lvName3, HypeLayer.back(), description.material("GasHe_90Isob_10"))); - lvLayerVol.back().setVisAttributes(description, gascol); + //HypeLayer.push_back(dd4hep::Hyperboloid(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, zlength)); + //lvLayerVol.push_back(dd4hep::Volume(lvName3, HypeLayer.back(), description.material("GasHe_90Isob_10"))); + //lvLayerVol.back().setVisAttributes(description, gascol); + + // Create hyperboloid volume of the whole ring for cellID definition + wholeHyperboloidVolumeName = dd4hep::_toString(SL, "hyperboloid_SL_%d") + dd4hep::_toString(iring, "_ring_%d"); + dd4hep::Hyperboloid whole_ring_hyperboloid = dd4hep::Hyperboloid(radius_ringIn_whole_cell, epsilonIn_whole_cell, radius_ringOut_0, epsilonOut, zlength); + dd4hep::Volume whole_ring_hyperboloid_volume = dd4hep::Volume(wholeHyperboloidVolumeName, whole_ring_hyperboloid, description.material("GasHe_90Isob_10")); + whole_ring_hyperboloid_volume.setVisAttributes(description, gascol); + //whole_ring_hyperboloid_volume.setSensitiveDetector(sens_det); + registerVolume(wholeHyperboloidVolumeName, whole_ring_hyperboloid_volume); + cout << "Placing Volume: " << wholeHyperboloidVolumeName << endl; + //parentVol.placeVolume(volume(wholeHyperboloidVolumeName)); + dd4hep::PlacedVolume whole_ring_hyperboloid_placedVolume; + whole_ring_hyperboloid_placedVolume = parentVol.placeVolume(whole_ring_hyperboloid_volume); + //CDCHDetector.setPlacement(whole_ring_hyperboloid_placedVolume); + whole_ring_hyperboloid_placedVolume.addPhysVolID("superLayer", SL).addPhysVolID("ring", iring); //------------------------------------------------------------------------ // Reduce zlength to avoid volume extrusions @@ -595,19 +677,95 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { // call the magic function. This is the top of the cell. //------------------------------------------------------------------------ - w.layer = lvLayerVol.back(); - w.type = "F"; - w.num = nFWire1; - w.radius = radius_ringIn_0 - FWradii - extShiftFW; - w.theta = theta_ring1; - w.thetaoffset = ringangle + cellStaggering; - w.stereo = sign_epsilon * epsilon; - w.halfalpha = halfalpha; - w.thickness = 0.5 * FWireShellThickIn * enlarge; - w.halflength = zlength; - w.volume = lvFwireVol.back(); - - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, iring); + field_wires_top.type = string("F"); + field_wires_top.num = nFWire1; + field_wires_top.radius = radius_ringIn_0 - FWradii - extShiftFW; + field_wires_top.phi = phi_ring1; + field_wires_top.phioffset = ringangle + cellStaggering; + field_wires_top.stereo = sign_epsilon * epsilon; + field_wires_top.halfalpha = halfalpha; + field_wires_top.thickness = 0.5 * FWireShellThickIn * enlarge; + field_wires_top.halflength = zlength; + field_wires_top.volume = lvFwireVol.back(); + field_wires_top.name = dd4hep::_toString(SL, "lvWire_SL%d") + dd4hep::_toString(iring, "_ring%d") + string("_type") + field_wires_top.type + dd4hep::_toString(field_wires_top.stereo, "_stereo%f_top"); + //field_wires_top.name = "lvWire_SL" + std::to_string(SL) + "_ring" + std::to_string(iring) + "_type" + field_wires_top.type + "_stereo" + std::to_string(field_wires_top.stereo) + "_top"; + apply_wire_coating(field_wires_top, FWireShellThickOut, halflength); + + //if(setWireSensitive){ + // field_wires_bottom.volume.setSensitiveDetector(sens_det); + // field_wires_center.volume.setSensitiveDetector(sens_det); + // sense_wires.volume.setSensitiveDetector(sens_det); + // field_wires_top.volume.setSensitiveDetector(sens_det); + //} + + // arbitrarily extended tube section to build the sensitive volume ID associated to the wire from boolean operation with the layer hyperboloid + dd4hep::Tube cellID_tube_for_boolean(0, sense_wires.radius * 2, halflength, - sense_wires.phi / 2.0, sense_wires.phi / 2.0); + dd4hep::IntersectionSolid cellID_shape; + dd4hep::PlacedVolume cellID_placedvolume; + string cellID_volume_name; + dd4hep::Volume cellID_volume; + dd4hep::PlacedVolume field_wire_bottom_placedvolume; + dd4hep::PlacedVolume sense_wire_placedvolume; + dd4hep::PlacedVolume field_wire_center_placedvolume; + dd4hep::PlacedVolume field_wire_top_placedvolume; + + // Radial translation + dd4hep::Translation3D radial_translation_sense_wire(sense_wires.radius, 0., 0.); + // stereo rotation + dd4hep::RotationX rot_stereo_sense_wire(sense_wires.stereo); + // extract the number of wire ratio to place field wires in the loop for sense wires + // it is not very elegant but the sense wire define the sensitive volume in which wires are placed + float middle_to_middle_num_wire_ratio = field_wires_center.num/float(sense_wires.num); + float middle_to_bottom_num_wire_ratio = field_wires_bottom.num/float(sense_wires.num); + float middle_to_top_num_wire_ratio = field_wires_top.num/float(sense_wires.num); + if(ceilf(middle_to_middle_num_wire_ratio) != middle_to_middle_num_wire_ratio || ceilf(middle_to_bottom_num_wire_ratio) != middle_to_bottom_num_wire_ratio || ceilf(middle_to_top_num_wire_ratio) != middle_to_top_num_wire_ratio) + throw std::runtime_error("Error: Failed to build CDCH. Please make sure that the number of wires in top/center cell rings is always a multiple of the number of wires in the middle of the cell"); + // loop to arrange the wires in phi, starting with the sense wires to be able to build the volume associated to the cell + for (int phi_index = 0; phi_index < sense_wires.num; phi_index++) { + // Prepare the cell sensitive volume as the intersection of the hyperboloid and a rotated tube segment + // phi rotation + dd4hep::RotationZ iRot(sense_wires.phioffset + sense_wires.phi * phi_index); + // complete transformation for the sense wires + dd4hep::Transform3D total_transformation(iRot * radial_translation_sense_wire * rot_stereo_sense_wire); + // create the intersection of the tube with the hyperboloid after rotating the tube in phi and stereo angle + cellID_shape = dd4hep::IntersectionSolid(whole_ring_hyperboloid, cellID_tube_for_boolean, dd4hep::Transform3D(dd4hep::RotationZ(sense_wires.phioffset + sense_wires.phi * phi_index) * dd4hep::RotationX(sense_wires.stereo))); + cellID_volume_name = dd4hep::_toString(SL, "cellIDvolume_SL_%d") + dd4hep::_toString(iring, "_ring_%d") + dd4hep::_toString(phi_index, "_phi_%d"); + cellID_volume = dd4hep::Volume(cellID_volume_name, cellID_shape, description.material("GasHe_90Isob_10")); + cellID_volume.setVisAttributes(description, gascol); + cellID_volume.setSensitiveDetector(sens_det); + cellID_placedvolume = whole_ring_hyperboloid_volume.placeVolume(cellID_volume); + cellID_placedvolume.addPhysVolID("phi", phi_index).addPhysVolID("hitorigin", 0).addPhysVolID("stereo", sense_wires.stereo > 0 ? 0 : 1).addPhysVolID("layerInCell", 0); + + // place the wires. The transformation is: apply the stereo angle rotation, translate the wire to the required radius, apply the phi rotation + // sense wires in the radial middle of the cell + sense_wire_placedvolume = cellID_volume.placeVolume(sense_wires.volume, total_transformation); + + // bottom field wires + for(int sub_phi_index = phi_index * middle_to_bottom_num_wire_ratio; sub_phi_index < (phi_index * middle_to_bottom_num_wire_ratio) + middle_to_bottom_num_wire_ratio; sub_phi_index++){ + field_wire_bottom_placedvolume = cellID_volume.placeVolume(field_wires_bottom.volume, dd4hep::Transform3D(dd4hep::RotationZ(field_wires_bottom.phioffset + field_wires_bottom.phi * sub_phi_index) * dd4hep::Translation3D(field_wires_bottom.radius, 0., 0.) *dd4hep::RotationX(field_wires_bottom.stereo))); + //if(setWireSensitive) + // field_wire_bottom_placedvolume.addPhysVolID("phi", sub_phi_index).addPhysVolID("hitorigin", 2).addPhysVolID("stereo", field_wires_center.stereo > 0 ? 0 : 1).addPhysVolID("layerInCell", 1); + } + + // central field wires + for(int sub_phi_index = phi_index * middle_to_middle_num_wire_ratio; sub_phi_index < (phi_index * middle_to_middle_num_wire_ratio) + middle_to_middle_num_wire_ratio; sub_phi_index++){ + field_wire_center_placedvolume = cellID_volume.placeVolume(field_wires_center.volume, dd4hep::Transform3D(dd4hep::RotationZ(field_wires_center.phioffset + field_wires_center.phi * sub_phi_index) * dd4hep::Translation3D(field_wires_center.radius, 0., 0.) *dd4hep::RotationX(field_wires_center.stereo))); + //if(setWireSensitive) + // field_wire_center_placedvolume.addPhysVolID("phi", sub_phi_index).addPhysVolID("hitorigin", 2).addPhysVolID("stereo", field_wires_center.stereo > 0 ? 0 : 1).addPhysVolID("layerInCell", 2); + } + + // top field wires + for(int sub_phi_index = phi_index * middle_to_top_num_wire_ratio; sub_phi_index < (phi_index * middle_to_top_num_wire_ratio) + middle_to_top_num_wire_ratio; sub_phi_index++){ + field_wire_top_placedvolume = cellID_volume.placeVolume(field_wires_top.volume, dd4hep::Transform3D(dd4hep::RotationZ(field_wires_top.phioffset + field_wires_top.phi * sub_phi_index) * dd4hep::Translation3D(field_wires_top.radius, 0., 0.) *dd4hep::RotationX(field_wires_top.stereo))); + //if(setWireSensitive) + // field_wire_top_placedvolume.addPhysVolID("phi", sub_phi_index).addPhysVolID("hitorigin", 2).addPhysVolID("stereo", field_wires_center.stereo > 0 ? 0 : 1).addPhysVolID("layerInCell", 3); + } + } + + //CDCHBuild::PlaceWires(field_wires_bottom, FWireShellThickOut, halflength, 0, SL, iring); + //CDCHBuild::PlaceWires(sense_wires, FWireShellThickOut, halflength, 0, SL, iring, sens_det, parentVol); + //CDCHBuild::PlaceWires(field_wires_center, FWireShellThickOut, halflength, 0, SL, iring); + //CDCHBuild::PlaceWires(field_wires_top, FWireShellThickOut, halflength, 0, SL, iring); //------------------------------------------------------------------------ // Scale the delta radius of the ring for next iteration @@ -633,25 +791,25 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { zlength -= sin(epsilon) * FWradii; zlength /= cos(epsilon); - w.layer = lvLayerVol.back(); - w.type = "F"; - w.num = nFWire1; - w.radius = radius_ringIn_0 + FWradii + extShiftFW; - w.theta = theta_ring1; - w.thetaoffset = ringangle + cellStaggering + theta_ring; - w.stereo = -1. * sign_epsilon * epsilon; - w.halfalpha = halfalpha; - w.thickness = 0.5 * FWireShellThickIn * enlarge; - w.halflength = zlength; + field_wires_bottom.mother_volume = lvLayerVol.back(); + field_wires_bottom.type = string("F"); + field_wires_bottom.num = nFWire1; + field_wires_bottom.radius = radius_ringIn_0 + FWradii + extShiftFW; + field_wires_bottom.phi = phi_ring1; + field_wires_bottom.phioffset = ringangle + cellStaggering + phi_ring; + field_wires_bottom.stereo = -1. * sign_epsilon * epsilon; + field_wires_bottom.halfalpha = halfalpha; + field_wires_bottom.thickness = 0.5 * FWireShellThickIn * enlarge; + field_wires_bottom.halflength = zlength; lvFwireName = dd4hep::_toString(SL, "lvFwire_%d_out"); - dd4hep::Tube Fwire(0.0, w.thickness, halflength); + dd4hep::Tube Fwire(0.0, field_wires_bottom.thickness, halflength); lvFwireVol.push_back(dd4hep::Volume(lvFwireName, Fwire, description.material("G4_Al"))); lvFwireVol.back().setVisAttributes(description, wirecol); - w.volume = lvFwireVol.back(); - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, -1); + field_wires_bottom.volume = lvFwireVol.back(); + //CDCHBuild::PlaceWires(field_wires_bottom, FWireShellThickOut, halflength, 0, SL, -1); //------------------------------------------------------------------------ // Start placing the outer layer of guard wires @@ -674,42 +832,42 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { zlength -= sin(epsilonOutGwRing) * inGWradii; zlength /= cos(epsilonOutGwRing); - w.layer = lvLayerVol.back(); - w.type = "G"; - w.num = nOutGWire / 2; - w.radius = outGuardRad - inGWradii; - w.theta = theta_ring1; - w.thetaoffset = ringangle; - w.stereo = epsilonOutGwRing; - w.halfalpha = halfalpha; - w.thickness = 0.5 * OutGWireShellThickIn * enlarge; - w.halflength = zlength; - - dd4hep::Tube Gwire(0.0, w.thickness, halflength); + guard_wires.mother_volume = lvLayerVol.back(); + guard_wires.type = string("G"); + guard_wires.num = nOutGWire / 2; + guard_wires.radius = outGuardRad - inGWradii; + guard_wires.phi = phi_ring1; + guard_wires.phioffset = ringangle; + guard_wires.stereo = epsilonOutGwRing; + guard_wires.halfalpha = halfalpha; + guard_wires.thickness = 0.5 * OutGWireShellThickIn * enlarge; + guard_wires.halflength = zlength; + + dd4hep::Tube Gwire(0.0, guard_wires.thickness, halflength); lvGwireVol.push_back(dd4hep::Volume("Gwire_outer", Gwire, description.material("G4_Al"))); lvGwireVol.back().setVisAttributes(description, wirecol); - w.volume = lvGwireVol.back(); - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, 0, SL, -1); + guard_wires.volume = lvGwireVol.back(); + //CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, 0, SL, -1); - w.radius = outGuardRad + inGWradii + extShiftFW; - w.thetaoffset = ringangle + theta_ring; - w.stereo = -1.0 * epsilonOutGwRing; - CDCHBuild::PlaceWires(w, FWireShellThickOut, halflength, nOutGWire / 2, SL, -1); + guard_wires.radius = outGuardRad + inGWradii + extShiftFW; + guard_wires.phioffset = ringangle + phi_ring; + guard_wires.stereo = -1.0 * epsilonOutGwRing; + //CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, nOutGWire / 2, SL, -1); } } - dd4hep::PlacedVolume pv; - dd4hep::DetElement CDCHDetector(parent, "Ecal_DP", parent.id()); Int_t sizeLayer = lvLayerVol.size(); - for (Int_t i = 0; i < sizeLayer; i++) { - registerVolume(lvLayerVol.at(i).name(), lvLayerVol.at(i)); - cout << "Placing Volume: " << lvLayerVol.at(i).name() << endl; - pv = parentVol.placeVolume(volume(lvLayerVol.at(i).name())); - CDCHDetector.setPlacement(pv); - } + + //for (Int_t i = 0; i < sizeLayer; i++) { + // registerVolume(lvLayerVol.at(i).name(), lvLayerVol.at(i)); + // //cout << "Placing Volume: " << lvLayerVol.at(i).name() << endl; + // //pv = parentVol.placeVolume(volume(lvLayerVol.at(i).name())); + // //CDCHDetector.setPlacement(pv); + // parentVol.placeVolume(volume(lvLayerVol.at(i).name())); + //} double PosEndcapGas = halflength + 0.5 * GasEndcapWallThick; double PosEndcapCopper = halflength + GasEndcapWallThick + 0.5 * CopperEndcapWallThick; @@ -733,10 +891,10 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol) { parentVol.placeVolume(lvEndcapWallKapton, dd4hep::Position(0., 0., -PosEndcapKapton)); parentVol.placeVolume(lvEndcapWallCarbon, dd4hep::Position(0., 0., -PosEndcapCarbon)); } - -} // namespace +} //namespace static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4hep::SensitiveDetector sens_det) { + cout << "#####################" << endl; xml_det_t x_det = e; CDCHBuild builder(description, x_det, sens_det); @@ -761,7 +919,7 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4h // Build CDCH cable // ****************************************************** - builder.build_layer(CDCH_det, envelope); + builder.build_layer(CDCH_det, envelope, sens_det); // ****************************************************** // Build CDCH cell and beam plug From 7542c569122418c0835c1bc0dee39998c21c6d05 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 20 Jul 2023 17:19:04 +0200 Subject: [PATCH 03/20] [DriftChamber] Fix the guard wire layers --- .../IDEA_o1_v01/DriftChamber_parameters.xml | 4 +- .../DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 324 +++++++++--------- 2 files changed, 161 insertions(+), 167 deletions(-) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml index 54c95a8c..5b6b4523 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml @@ -26,8 +26,8 @@ - - + + - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/DriftChamber_parameters.xml b/Detector/DetFCCeeIDEA/compact/DriftChamber_parameters.xml index 05e1d868..cf5163cd 100644 --- a/Detector/DetFCCeeIDEA/compact/DriftChamber_parameters.xml +++ b/Detector/DetFCCeeIDEA/compact/DriftChamber_parameters.xml @@ -1,18 +1,6 @@ - - - From f4aea3700ed568193fee2a7a094be8050e3ef545 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Mon, 24 Jul 2023 13:55:48 +0200 Subject: [PATCH 05/20] [DriftChamber] ring --> layer --- .../compact/IDEA_o1_v01/DriftChamber.xml | 2 +- .../IDEA_o1_v01/DriftChamber_parameters.xml | 6 +- .../DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 276 +++++++++--------- 3 files changed, 142 insertions(+), 142 deletions(-) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml index c715c88b..a86cfd80 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml @@ -20,7 +20,7 @@ - system:4,superLayer:5,ring:5,phi:11,hitorigin:3,stereo:1,layerInCell:2 + system:4,superLayer:5,layer:5,phi:11,hitorigin:3,stereo:1,layerInCell:2 diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml index 5b6b4523..b16804ae 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml @@ -27,11 +27,11 @@ - + + --> diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index b2a75139..bd1cb88e 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -40,7 +40,7 @@ struct CDCHBuild : public dd4hep::xml::tools::VolumeBuilder { double diff_of_squares(double a, double b); void apply_wire_coating(struct wire& w, double outwrap, double halflength, string material); - void PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset, int SL, int iring); + void PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset, int SL, int ilayer); void build_layer(DetElement parent, Volume parentVol, dd4hep::SensitiveDetector sens); }; @@ -69,7 +69,7 @@ void CDCHBuild::apply_wire_coating(struct wire& w, double outwrap, double halfle // deprecated function, only use it for the wires before and after the sensitive zone (mainly guard wires) void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset = 0, int SL = 999, - int iring = 999) { + int ilayer = 999) { dd4hep::RotationZYX rot(0., 0., w.stereo); dd4hep::RotationX rot_stereo(w.stereo); @@ -79,8 +79,8 @@ void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, in string wirewrapname = "WireWrap_SL"; wirewrapname += std::to_string(SL); - wirewrapname += "_ring"; - wirewrapname += std::to_string(iring); + wirewrapname += "_layer"; + wirewrapname += std::to_string(ilayer); wirewrapname += "_type"; wirewrapname += w.type; wirewrapname += "_stereo"; @@ -90,8 +90,8 @@ void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, in string wirename = "Wire_SL"; wirename += std::to_string(SL); - wirename += "_ring"; - wirename += std::to_string(iring); + wirename += "_layer"; + wirename += std::to_string(ilayer); wirename += "_type"; wirename += w.type; wirename += "_stereo"; @@ -155,13 +155,13 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti int nStoFWireRatio = dd4hep::_toInt("CDCH:nStoFWireRatio"); int nVerticalFWire = dd4hep::_toInt("CDCH:nVerticalFWire"); int nSuperLayer = dd4hep::_toInt("CDCH:nSuperLayer"); - int nRing = dd4hep::_toInt("CDCH:nRing"); + int nLayer = dd4hep::_toInt("CDCH:nLayer"); int nFieldWireShells = dd4hep::_toInt("CDCH:nFieldWireShells"); //bool setWireSensitive = true; // FIXME: add the possibility to have wires sensitive (parameter in the xml) which could be useful for detailed chamber behavior studies, current attempt never lead to a hit in the wire, even with enlarged wires... double epsilon = 0.0; - double phi_ring = 0.0; - double phi_ring1 = 0.0; + double phi_layer = 0.0; + double phi_layer1 = 0.0; int nFWire = 0; int nFWire1 = 0; int num_wire = 0; @@ -171,7 +171,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti double scaleFactor = 0.0; double dropFactor = 0.0; double epsilonFactor = 0.0; - double delta_radius_ring = cellDimension; + double delta_radius_layer = cellDimension; double senseWireRing_radius_0 = 0.0; double iradius = 0.0; double idelta_radius = 0.0; @@ -190,17 +190,17 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti double fakeLayerInIWthick = -0.0001 + GasInnerWallThick; double inner_radius_0 = inner_radius + envelop_Inner_thickness - fakeLayerInIWthick; - double radius_ring_0 = inner_radius + envelop_Inner_thickness + FWradii + secure + capGasLayer; - double radius_ringOut_0 = radius_ring_0 - FWradii - secure; + double radius_layer_0 = inner_radius + envelop_Inner_thickness + FWradii + secure + capGasLayer; + double radius_layerOut_0 = radius_layer_0 - FWradii - secure; double drop = 0.0; - double radius_ring = 0.0; - double radius_ringIn_0 = 0.0; - double radius_ringIn = 0.0; - double radius_ringOut = 0.0; + double radius_layer = 0.0; + double radius_layerIn_0 = 0.0; + double radius_layerIn = 0.0; + double radius_layerOut = 0.0; double epsilonIn = 0.0; double epsilonOut = 0.0; - double ringangle = 0.0; + double layerangle = 0.0; double cellBase = 0.0; double inscribedRadius = 0.0; double circumscribedRadius = 0.0; @@ -208,7 +208,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti double cellStaggering = 0.0; double epsilonInGwRing = 0.0; double epsilonOutGwRing = 0.0; - double radius_ringIn_whole_cell = 0.0; + double radius_layerIn_whole_cell = 0.0; double epsilonIn_whole_cell = 0.0; //------------------------------------------------------------------------ @@ -285,15 +285,15 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti num_wire = nSWire + SL * nSDeltaWire; phi = 2. * TMath::Pi() / num_wire; nFWire = nHorizontalFWire * num_wire; - phi_ring = 2. * TMath::Pi() / nFWire; + phi_layer = 2. * TMath::Pi() / nFWire; nFWire1 = nFWire / 2; if (ceilf(nFWire1) != nFWire1) throw std::runtime_error("Error: Failed to build CDCH. Please make sure that '(nStoFWireRatio - nVerticalFWire) * (nSWire + SuperLayerIndex * nSDeltaWire)' is always an even number"); - phi_ring1 = 2.0 * phi_ring; + phi_layer1 = 2.0 * phi_layer; scaleFactor = (1.0 + TMath::Pi() / num_wire) / (1.0 - TMath::Pi() / num_wire); dropFactor = (1.0 / cos(halfalpha) - 1.0); epsilonFactor = sin(halfalpha) / halflength; - ringangle = -0.5 * phi; + layerangle = -0.5 * phi; gascol = "vCDCH:Gas1"; if (SL % 3 == 0) @@ -312,9 +312,9 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti if (SL == 0) {// SL = 0 is special due to the guard wires and the first field wires that lie outside of the sensitive volume // FIXME there are some volume extrusion here (wire go outside of the hyperboloid) - double stereoOut0 = atan(radius_ringOut_0 * (1.0 * dropFactor * epsilonFactor)); + double stereoOut0 = atan(radius_layerOut_0 * (1.0 * dropFactor * epsilonFactor)); - dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_ringOut_0 - secure, stereoOut0, halflength); + dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_layerOut_0 - secure, stereoOut0, halflength); lvLayerVol.push_back(dd4hep::Volume("lvLayerInit", HypeLayer0, description.material("GasHe_90Isob_10"))); lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); @@ -328,7 +328,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.num = nInGWire; guard_wires.radius = inGuardRad - inGWradii; guard_wires.phi = 2. * TMath::Pi() / guard_wires.num; - guard_wires.phioffset = ringangle; + guard_wires.phioffset = layerangle; guard_wires.stereo = epsilonInGwRing; guard_wires.halfalpha = halfalpha; guard_wires.thickness = 0.5 * InGWireShellThickIn * enlarge; // half the inner thickness as radius of tube @@ -343,22 +343,22 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, 0, SL, -1); guard_wires.radius = inGuardRad + inGWradii + extShiftFW; - guard_wires.phioffset = ringangle + phi_ring; + guard_wires.phioffset = layerangle + phi_layer; guard_wires.stereo = -1.0 * epsilonInGwRing; guard_wires.name = string("Gwire_inner_stereominus"); CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, nInGWire / 2, SL, -1); - drop = radius_ring_0 * dropFactor; - radius_ring = radius_ring_0 + drop; - epsilon = atan(radius_ring * epsilonFactor); - radius_ringIn_0 = radius_ring_0 - FWradii - 2.0 * secure; - radius_ringIn = radius_ringIn_0 + drop; - radius_ringOut_0 = radius_ring_0 + FWradii; - radius_ringOut = radius_ringOut_0 + drop; - epsilonIn = atan(sqrt(pow(radius_ringIn, 2) - pow(radius_ringIn_0, 2)) / halflength); - epsilonOut = atan(sqrt(pow(radius_ringOut, 2) - pow(radius_ringOut_0, 2)) / halflength); - - dd4hep::Hyperboloid HypeLayer1(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, halflength); + drop = radius_layer_0 * dropFactor; + radius_layer = radius_layer_0 + drop; + epsilon = atan(radius_layer * epsilonFactor); + radius_layerIn_0 = radius_layer_0 - FWradii - 2.0 * secure; + radius_layerIn = radius_layerIn_0 + drop; + radius_layerOut_0 = radius_layer_0 + FWradii; + radius_layerOut = radius_layerOut_0 + drop; + epsilonIn = atan(sqrt(pow(radius_layerIn, 2) - pow(radius_layerIn_0, 2)) / halflength); + epsilonOut = atan(sqrt(pow(radius_layerOut, 2) - pow(radius_layerOut_0, 2)) / halflength); + + dd4hep::Hyperboloid HypeLayer1(radius_layerIn_0, epsilonIn, radius_layerOut_0, epsilonOut, halflength); lvLayerVol.push_back(dd4hep::Volume("lvLayer_0", HypeLayer1, description.material("GasHe_90Isob_10"))); lvLayerVol.back().setVisAttributes(description, "vCDCH:Plastic"); @@ -369,9 +369,9 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_top.mother_volume = lvLayerVol.back(); field_wires_top.type = "F"; field_wires_top.num = nFWire1; - field_wires_top.radius = radius_ringIn_0 - FWradii - extShiftFW; + field_wires_top.radius = radius_layerIn_0 - FWradii - extShiftFW; field_wires_top.phi = 2. * TMath::Pi() /field_wires_top.num;; - field_wires_top.phioffset = ringangle + cellStaggering - phi_ring; + field_wires_top.phioffset = layerangle + cellStaggering - phi_layer; field_wires_top.stereo = sign_epsilon * epsilon; field_wires_top.halfalpha = halfalpha; field_wires_top.thickness = 0.5 * FWireShellThickIn * enlarge; @@ -387,20 +387,20 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_top.volume = lvFwireVol.back(); CDCHBuild::PlaceWires(field_wires_top, FWireShellThickOut, halflength, 0, SL, -1); - radius_ring_0 += FWradii; + radius_layer_0 += FWradii; // the commented part below is a trial to get totally rid of PlaceWire function and to treat wires outside of the sensitive volume the same way as the one inside //// deal with the first guard layer - //double stereoOut0 = atan((radius_ringOut_0 + FWradii) * (1.0 * dropFactor * epsilonFactor)); - ////stereoOut0 = atan(sqrt(diff_of_squares(radius_ringOut_0 + FWradii, - - ////radius_ringOut_0 = radius_ringIn_0 + FWireDiameter + 2.0 * secure; - ////radius_ringOut = radius_ringOut_0 + drop; - ////epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); - ////dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_ringOut_0 + FWradii - secure, stereoOut0, halflength); - //dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_ringOut_0 + FWradii, stereoOut0, halflength); + //double stereoOut0 = atan((radius_layerOut_0 + FWradii) * (1.0 * dropFactor * epsilonFactor)); + ////stereoOut0 = atan(sqrt(diff_of_squares(radius_layerOut_0 + FWradii, + + ////radius_layerOut_0 = radius_layerIn_0 + FWireDiameter + 2.0 * secure; + ////radius_layerOut = radius_layerOut_0 + drop; + ////epsilonOut = atan(sqrt(diff_of_squares(radius_layerOut, radius_layerOut_0)) / halflength); + ////dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_layerOut_0 + FWradii - secure, stereoOut0, halflength); + //dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_layerOut_0 + FWradii, stereoOut0, halflength); //dd4hep::Volume inner_guard_layer_volume("hyperboloid_inner_guard_layer", HypeLayer0, description.material("GasHe_90Isob_10")); //dd4hep::PlacedVolume inner_guard_layer_placedVolume = parentVol.placeVolume(inner_guard_layer_volume); //CDCHDetector.setPlacement(inner_guard_layer_placedVolume); @@ -415,7 +415,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti //guard_wires.num = nInGWire; //guard_wires.radius = inGuardRad - inGWradii; //guard_wires.phi = 2. * TMath::Pi() / guard_wires.num; - //guard_wires.phioffset = ringangle; + //guard_wires.phioffset = layerangle; //guard_wires.stereo = epsilonInGwRing; //guard_wires.halfalpha = halfalpha; //guard_wires.thickness = 0.5 * InGWireShellThickIn * enlarge; // half the inner thickness as radius of tube @@ -438,21 +438,21 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti //} //guard_wires.radius = inGuardRad + inGWradii + extShiftFW; - //guard_wires.phioffset = ringangle + phi_ring; + //guard_wires.phioffset = layerangle + phi_layer; //guard_wires.stereo = -1.0 * epsilonInGwRing; //guard_wires.name = string("InnerGuardWire") + dd4hep::_toString(guard_wires.stereo, "_stereo%f"); - //drop = radius_ring_0 * dropFactor; - //radius_ring = radius_ring_0 + drop; - //epsilon = atan(radius_ring * epsilonFactor); - //radius_ringIn_0 = radius_ring_0 - FWradii - 2.0 * secure; - //radius_ringIn = radius_ringIn_0 + drop; - //radius_ringOut_0 = radius_ring_0 + FWradii; - //radius_ringOut = radius_ringOut_0 + drop; - //epsilonIn = atan(sqrt(pow(radius_ringIn, 2) - pow(radius_ringIn_0, 2)) / halflength); - //epsilonOut = atan(sqrt(pow(radius_ringOut, 2) - pow(radius_ringOut_0, 2)) / halflength); - - //dd4hep::Hyperboloid HypeLayer1(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, halflength); + //drop = radius_layer_0 * dropFactor; + //radius_layer = radius_layer_0 + drop; + //epsilon = atan(radius_layer * epsilonFactor); + //radius_layerIn_0 = radius_layer_0 - FWradii - 2.0 * secure; + //radius_layerIn = radius_layerIn_0 + drop; + //radius_layerOut_0 = radius_layer_0 + FWradii; + //radius_layerOut = radius_layerOut_0 + drop; + //epsilonIn = atan(sqrt(pow(radius_layerIn, 2) - pow(radius_layerIn_0, 2)) / halflength); + //epsilonOut = atan(sqrt(pow(radius_layerOut, 2) - pow(radius_layerOut_0, 2)) / halflength); + + //dd4hep::Hyperboloid HypeLayer1(radius_layerIn_0, epsilonIn, radius_layerOut_0, epsilonOut, halflength); //lvLayerVol.push_back(dd4hep::Volume("lvLayer_0", HypeLayer1, description.material("GasHe_90Isob_10"))); //lvLayerVol.back().setVisAttributes(description, "vCDCH:Plastic"); @@ -463,14 +463,14 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti //field_wires_top.mother_volume = lvLayerVol.back(); //field_wires_top.type = "F"; //field_wires_top.num = nFWire1; - //field_wires_top.radius = radius_ringIn_0 - FWradii - extShiftFW; - //field_wires_top.phi = phi_ring1; - //field_wires_top.phioffset = ringangle + cellStaggering - phi_ring; + //field_wires_top.radius = radius_layerIn_0 - FWradii - extShiftFW; + //field_wires_top.phi = phi_layer1; + //field_wires_top.phioffset = layerangle + cellStaggering - phi_layer; //field_wires_top.stereo = sign_epsilon * epsilon; //field_wires_top.halfalpha = halfalpha; //field_wires_top.thickness = 0.5 * FWireShellThickIn * enlarge; //field_wires_top.halflength = zlength; - //field_wires_top.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(-1, "_ring%d") + string("_type") + field_wires_top.type + dd4hep::_toString(field_wires_top.stereo, "_stereo%f_top"); + //field_wires_top.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(-1, "_layer%d") + string("_type") + field_wires_top.type + dd4hep::_toString(field_wires_top.stereo, "_stereo%f_top"); //lvFwireName = dd4hep::_toString(SL, "lvFwire_%d_init"); @@ -481,40 +481,40 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti ////field_wires_top.volume = lvFwireVol.back(); //////CDCHBuild::PlaceWires(field_wires_top, FWireShellThickOut, halflength, 0, SL, -1); - //radius_ring_0 += FWradii; + //radius_layer_0 += FWradii; } else { - delta_radius_ring = 2. * TMath::Pi() * radius_ringOut_0 / (num_wire - TMath::Pi()); + delta_radius_layer = 2. * TMath::Pi() * radius_layerOut_0 / (num_wire - TMath::Pi()); } //------------------------------------------------------------------------ - // Starting the layer ("ring") loop. nRing=8 + // Starting the layer loop. nLayer=8 //------------------------------------------------------------------------ - for (int iring = 0; iring < nRing; iring++) { + for (int ilayer = 0; ilayer < nLayer; ilayer++) { //------------------------------------------------------------------------ // Fill the geometry parameters of the layer. Each layer lies - // on top of the following one, so new ringIn = old ringOut + // on top of the following one, so new layerIn = old layerOut //------------------------------------------------------------------------ - inscribedRadius = 0.5 * delta_radius_ring; + inscribedRadius = 0.5 * delta_radius_layer; circumscribedRadius = inscribedRadius * sqrt(2.0); - senseWireRing_radius_0 = radius_ring_0 + inscribedRadius; + senseWireRing_radius_0 = radius_layer_0 + inscribedRadius; sign_epsilon *= -1; - radius_ringIn_0 = radius_ringOut_0; - radius_ringIn = radius_ringOut; + radius_layerIn_0 = radius_layerOut_0; + radius_layerIn = radius_layerOut; epsilonIn = epsilonOut; - radius_ringOut_0 = radius_ringIn_0 + FWireDiameter + 2.0 * secure; - radius_ringOut = radius_ringOut_0 + drop; - epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + radius_layerOut_0 = radius_layerIn_0 + FWireDiameter + 2.0 * secure; + radius_layerOut = radius_layerOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_layerOut, radius_layerOut_0)) / halflength); zlength = halflength; // save bottom layer inner radius and epsilon before they are modified to build the whole layer hyperboloid volume - radius_ringIn_whole_cell = radius_ringIn_0; + radius_layerIn_whole_cell = radius_layerIn_0; epsilonIn_whole_cell = epsilonIn; //------------------------------------------------------------------------ @@ -524,8 +524,8 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti zlength -= sin(epsilon) * FWradii; zlength /= cos(epsilon); - if (iring % 2 == 1) - cellStaggering = phi_ring; + if (ilayer % 2 == 1) + cellStaggering = phi_layer; else cellStaggering = 0.0; @@ -536,20 +536,20 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_bottom.type = "F"; field_wires_bottom.num = nFWire1; - field_wires_bottom.radius = radius_ringIn_0 + FWradii + extShiftFW; - field_wires_bottom.phi = phi_ring1; - field_wires_bottom.phioffset = ringangle + cellStaggering; + field_wires_bottom.radius = radius_layerIn_0 + FWradii + extShiftFW; + field_wires_bottom.phi = phi_layer1; + field_wires_bottom.phioffset = layerangle + cellStaggering; field_wires_bottom.stereo = sign_epsilon * epsilon; field_wires_bottom.halfalpha = halfalpha; field_wires_bottom.thickness = 0.5 * FWireShellThickIn * enlarge; field_wires_bottom.halflength = zlength; - field_wires_bottom.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(iring, "_ring%d") + string("_type") + field_wires_bottom.type + dd4hep::_toString(field_wires_bottom.stereo, "_stereo%f_bottom"); + field_wires_bottom.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(ilayer, "_layer%d") + string("_type") + field_wires_bottom.type + dd4hep::_toString(field_wires_bottom.stereo, "_stereo%f_bottom"); //------------------------------------------------------------------------ // Define the field wire name and build the field wire volume //------------------------------------------------------------------------ - lvFwireName = dd4hep::_toString(SL, "lvFwire_%d") + dd4hep::_toString(iring, "_%d"); + lvFwireName = dd4hep::_toString(SL, "lvFwire_%d") + dd4hep::_toString(ilayer, "_%d"); dd4hep::Tube Fwire(0.0, field_wires_bottom.thickness, halflength); lvFwireVol.push_back(dd4hep::Volume(lvFwireName, Fwire, description.material("G4_Al"))); @@ -566,16 +566,16 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti // Next, fill the geometry parameters of the central layer. //------------------------------------------------------------------------ - iradius = radius_ring_0; - radius_ring_0 += delta_radius_ring; - drop = radius_ring_0 * dropFactor; + iradius = radius_layer_0; + radius_layer_0 += delta_radius_layer; + drop = radius_layer_0 * dropFactor; - radius_ringIn_0 = radius_ringOut_0; - radius_ringIn = radius_ringOut; + radius_layerIn_0 = radius_layerOut_0; + radius_layerIn = radius_layerOut; epsilonIn = epsilonOut; - radius_ringOut_0 = radius_ring_0 - FWireDiameter - 2.0 * secure; - radius_ringOut = radius_ringOut_0 + drop; - epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + radius_layerOut_0 = radius_layer_0 - FWireDiameter - 2.0 * secure; + radius_layerOut = radius_layerOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_layerOut, radius_layerOut_0)) / halflength); zlength = halflength; //------------------------------------------------------------------------ @@ -598,13 +598,13 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti sense_wires.halfalpha = halfalpha; sense_wires.thickness = 0.5 * SWireShellThickIn * enlarge; sense_wires.halflength = zlength; - sense_wires.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(iring, "_ring%d") + string("_type") + sense_wires.type + dd4hep::_toString(sense_wires.stereo, "_stereo%f"); + sense_wires.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(ilayer, "_layer%d") + string("_type") + sense_wires.type + dd4hep::_toString(sense_wires.stereo, "_stereo%f"); //------------------------------------------------------------------------ // Define the sense wire name and build the sense wire volume //------------------------------------------------------------------------ - lvSwireName = dd4hep::_toString(SL, "lvSwire_%d") + dd4hep::_toString(iring, "_%d"); + lvSwireName = dd4hep::_toString(SL, "lvSwire_%d") + dd4hep::_toString(ilayer, "_%d"); dd4hep::Tube Swire(0.0, sense_wires.thickness, halflength); dd4hep::Volume lvSwireVol(lvSwireName, Swire, description.material("G4_W")); @@ -616,7 +616,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti // Tune the radius and epsilon of the central field wires //------------------------------------------------------------------------ - idelta_radius = delta_radius_ring * 0.5; + idelta_radius = delta_radius_layer * 0.5; iradius += idelta_radius; epsilon = atan(iradius * (1.0 + dropFactor) * epsilonFactor); @@ -628,13 +628,13 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_center.num = num_wire; field_wires_center.radius = iradius; field_wires_center.phi = phi; - field_wires_center.phioffset = ringangle + cellStaggering; + field_wires_center.phioffset = layerangle + cellStaggering; field_wires_center.stereo = sign_epsilon * epsilon; field_wires_center.halfalpha = halfalpha; field_wires_center.thickness = 0.5 * FWireShellThickIn * enlarge; field_wires_center.halflength = zlength; field_wires_center.volume = lvFwireVol.back(); - field_wires_center.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(iring, "_ring%d") + string("_type") + field_wires_center.type + dd4hep::_toString(field_wires_center.stereo, "_stereo%f_center"); + field_wires_center.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(ilayer, "_layer%d") + string("_type") + field_wires_center.type + dd4hep::_toString(field_wires_center.stereo, "_stereo%f_center"); apply_wire_coating(field_wires_center, FWireShellThickOut, halflength); @@ -642,26 +642,26 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti // Next, fill the geometry parameters of the upper layer. //------------------------------------------------------------------------ - radius_ringIn_0 = radius_ringOut_0; - radius_ringIn = radius_ringOut; + radius_layerIn_0 = radius_layerOut_0; + radius_layerIn = radius_layerOut; epsilonIn = epsilonOut; - radius_ringOut_0 = radius_ringIn_0 + FWireDiameter + 2.0 * secure; - radius_ringOut = radius_ringOut_0 + drop; - epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + radius_layerOut_0 = radius_layerIn_0 + FWireDiameter + 2.0 * secure; + radius_layerOut = radius_layerOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_layerOut, radius_layerOut_0)) / halflength); zlength = halflength; - // Create hyperboloid volume of the whole ring for the cell sensitive volume definition - wholeHyperboloidVolumeName = dd4hep::_toString(SL, "hyperboloid_SL_%d") + dd4hep::_toString(iring, "_ring_%d"); - dd4hep::Hyperboloid whole_ring_hyperboloid = dd4hep::Hyperboloid(radius_ringIn_whole_cell, epsilonIn_whole_cell, radius_ringOut_0, epsilonOut, zlength); - dd4hep::Volume whole_ring_hyperboloid_volume = dd4hep::Volume(wholeHyperboloidVolumeName, whole_ring_hyperboloid, description.material("GasHe_90Isob_10")); - whole_ring_hyperboloid_volume.setVisAttributes(description, gascol); - //whole_ring_hyperboloid_volume.setSensitiveDetector(sens_det); - //registerVolume(wholeHyperboloidVolumeName, whole_ring_hyperboloid_volume); + // Create hyperboloid volume of the whole layer for the cell sensitive volume definition + wholeHyperboloidVolumeName = dd4hep::_toString(SL, "hyperboloid_SL_%d") + dd4hep::_toString(ilayer, "_layer_%d"); + dd4hep::Hyperboloid whole_layer_hyperboloid = dd4hep::Hyperboloid(radius_layerIn_whole_cell, epsilonIn_whole_cell, radius_layerOut_0, epsilonOut, zlength); + dd4hep::Volume whole_layer_hyperboloid_volume = dd4hep::Volume(wholeHyperboloidVolumeName, whole_layer_hyperboloid, description.material("GasHe_90Isob_10")); + whole_layer_hyperboloid_volume.setVisAttributes(description, gascol); + //whole_layer_hyperboloid_volume.setSensitiveDetector(sens_det); + //registerVolume(wholeHyperboloidVolumeName, whole_layer_hyperboloid_volume); //parentVol.placeVolume(volume(wholeHyperboloidVolumeName)); - dd4hep::PlacedVolume whole_ring_hyperboloid_placedVolume; - whole_ring_hyperboloid_placedVolume = parentVol.placeVolume(whole_ring_hyperboloid_volume); - CDCHDetector.setPlacement(whole_ring_hyperboloid_placedVolume); - whole_ring_hyperboloid_placedVolume.addPhysVolID("superLayer", SL).addPhysVolID("ring", iring); + dd4hep::PlacedVolume whole_layer_hyperboloid_placedVolume; + whole_layer_hyperboloid_placedVolume = parentVol.placeVolume(whole_layer_hyperboloid_volume); + CDCHDetector.setPlacement(whole_layer_hyperboloid_placedVolume); + whole_layer_hyperboloid_placedVolume.addPhysVolID("superLayer", SL).addPhysVolID("layer", ilayer); //------------------------------------------------------------------------ // Reduce zlength to avoid volume extrusions @@ -677,15 +677,15 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_top.type = "F"; field_wires_top.num = nFWire1; - field_wires_top.radius = radius_ringIn_0 - FWradii - extShiftFW; - field_wires_top.phi = phi_ring1; - field_wires_top.phioffset = ringangle + cellStaggering; + field_wires_top.radius = radius_layerIn_0 - FWradii - extShiftFW; + field_wires_top.phi = phi_layer1; + field_wires_top.phioffset = layerangle + cellStaggering; field_wires_top.stereo = sign_epsilon * epsilon; field_wires_top.halfalpha = halfalpha; field_wires_top.thickness = 0.5 * FWireShellThickIn * enlarge; field_wires_top.halflength = zlength; field_wires_top.volume = lvFwireVol.back(); - field_wires_top.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(iring, "_ring%d") + string("_type") + field_wires_top.type + dd4hep::_toString(field_wires_top.stereo, "_stereo%f_top"); + field_wires_top.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(ilayer, "_layer%d") + string("_type") + field_wires_top.type + dd4hep::_toString(field_wires_top.stereo, "_stereo%f_top"); apply_wire_coating(field_wires_top, FWireShellThickOut, halflength); //if(setWireSensitive){ @@ -725,12 +725,12 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti // complete transformation for the sense wires dd4hep::Transform3D total_transformation(iRot * radial_translation_sense_wire * rot_stereo_sense_wire); // create the intersection of the tube with the hyperboloid after rotating the tube in phi and stereo angle - cellID_shape = dd4hep::IntersectionSolid(whole_ring_hyperboloid, cellID_tube_for_boolean, dd4hep::Transform3D(dd4hep::RotationZ(sense_wires.phioffset + sense_wires.phi * phi_index) * dd4hep::RotationX(sense_wires.stereo))); - cellID_volume_name = dd4hep::_toString(SL, "cellIDvolume_SL_%d") + dd4hep::_toString(iring, "_ring_%d") + dd4hep::_toString(phi_index, "_phi_%d"); + cellID_shape = dd4hep::IntersectionSolid(whole_layer_hyperboloid, cellID_tube_for_boolean, dd4hep::Transform3D(dd4hep::RotationZ(sense_wires.phioffset + sense_wires.phi * phi_index) * dd4hep::RotationX(sense_wires.stereo))); + cellID_volume_name = dd4hep::_toString(SL, "cellIDvolume_SL_%d") + dd4hep::_toString(ilayer, "_layer_%d") + dd4hep::_toString(phi_index, "_phi_%d"); cellID_volume = dd4hep::Volume(cellID_volume_name, cellID_shape, description.material("GasHe_90Isob_10")); cellID_volume.setVisAttributes(description, gascol); cellID_volume.setSensitiveDetector(sens_det); - cellID_placedvolume = whole_ring_hyperboloid_volume.placeVolume(cellID_volume); + cellID_placedvolume = whole_layer_hyperboloid_volume.placeVolume(cellID_volume); cellID_placedvolume.addPhysVolID("phi", phi_index).addPhysVolID("hitorigin", 0).addPhysVolID("stereo", sense_wires.stereo > 0 ? 0 : 1).addPhysVolID("layerInCell", 0); // place the wires. The transformation is: apply the stereo angle rotation, translate the wire to the required radius, apply the phi rotation @@ -760,23 +760,23 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti } //------------------------------------------------------------------------ - // Scale the delta radius of the ring for next iteration + // Scale the delta radius of the layer for next iteration //------------------------------------------------------------------------ - delta_radius_ring *= scaleFactor; + delta_radius_layer *= scaleFactor; } if (SL == (nSuperLayer - 1)) {// the last super layer is special since we need to add the field wires outside of the sensitive volume and the guard wires // Take care of the field wires outside of the sensitive volume - radius_ringIn_0 = radius_ringOut_0; - radius_ringIn = radius_ringOut; + radius_layerIn_0 = radius_layerOut_0; + radius_layerIn = radius_layerOut; epsilonIn = epsilonOut; - radius_ringOut_0 = radius_ring_0 + FWireDiameter + 2.0 * secure; - radius_ringOut = radius_ringOut_0 + drop; - epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + radius_layerOut_0 = radius_layer_0 + FWireDiameter + 2.0 * secure; + radius_layerOut = radius_layerOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_layerOut, radius_layerOut_0)) / halflength); - dd4hep::Hyperboloid HypeLayerOut(radius_ringIn_0, epsilonIn, radius_ringOut_0, epsilonOut, halflength); + dd4hep::Hyperboloid HypeLayerOut(radius_layerIn_0, epsilonIn, radius_layerOut_0, epsilonOut, halflength); lvLayerVol.push_back(dd4hep::Volume("lvLayerOut", HypeLayerOut, description.material("GasHe_90Isob_10"))); lvLayerVol.back().setVisAttributes(description, "vCDCH:Plastic"); @@ -787,9 +787,9 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_bottom.mother_volume = lvLayerVol.back(); field_wires_bottom.type = "F"; field_wires_bottom.num = nFWire1; - field_wires_bottom.radius = radius_ringIn_0 + FWradii + extShiftFW; + field_wires_bottom.radius = radius_layerIn_0 + FWradii + extShiftFW; field_wires_bottom.phi = 2. * TMath::Pi() / field_wires_bottom.num; - field_wires_bottom.phioffset = ringangle + cellStaggering + phi_ring; + field_wires_bottom.phioffset = layerangle + cellStaggering + phi_layer; field_wires_bottom.stereo = -1. * sign_epsilon * epsilon; field_wires_bottom.halfalpha = halfalpha; field_wires_bottom.thickness = 0.5 * FWireShellThickIn * enlarge; @@ -809,14 +809,14 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti // Start placing the outer layer of guard wires //------------------------------------------------------------------------ - radius_ringIn_0 = radius_ringOut_0; - radius_ringIn = radius_ringOut; + radius_layerIn_0 = radius_layerOut_0; + radius_layerIn = radius_layerOut; epsilonIn = epsilonOut; - radius_ringOut_0 = radius_ring_0 + FWireDiameter + 2.0 * secure; - radius_ringOut = radius_ringOut_0 + drop; - epsilonOut = atan(sqrt(diff_of_squares(radius_ringOut, radius_ringOut_0)) / halflength); + radius_layerOut_0 = radius_layer_0 + FWireDiameter + 2.0 * secure; + radius_layerOut = radius_layerOut_0 + drop; + epsilonOut = atan(sqrt(diff_of_squares(radius_layerOut, radius_layerOut_0)) / halflength); - dd4hep::Hyperboloid HypeLayerOutG(radius_ringIn_0, epsilonOut, outer_radius - envelop_Outer_thickness - 0.0001, + dd4hep::Hyperboloid HypeLayerOutG(radius_layerIn_0, epsilonOut, outer_radius - envelop_Outer_thickness - 0.0001, 0.0, halflength); lvLayerVol.push_back(dd4hep::Volume("lvLayerOutG", HypeLayerOutG, description.material("GasHe_90Isob_10"))); lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); @@ -831,7 +831,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.num = sense_wires.num; // To be checked guard_wires.radius = outGuardRad - inGWradii; guard_wires.phi = 2. * TMath::Pi() / guard_wires.num; - guard_wires.phioffset = ringangle; + guard_wires.phioffset = layerangle; guard_wires.stereo = epsilonOutGwRing; guard_wires.halfalpha = halfalpha; guard_wires.thickness = 0.5 * OutGWireShellThickIn * enlarge; @@ -846,7 +846,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, 0, SL, -1); guard_wires.radius = outGuardRad + inGWradii + extShiftFW; - guard_wires.phioffset = ringangle + phi_ring; + guard_wires.phioffset = layerangle + phi_layer; guard_wires.stereo = -1.0 * epsilonOutGwRing; CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, nOutGWire / 2, SL, -1); } From 830b378c7f193b13b41b63a991b4b73ff89d9b20 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Wed, 26 Jul 2023 11:09:45 +0200 Subject: [PATCH 06/20] [DriftChamber] Remove unused parameter in placeWires --- .../DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index bd1cb88e..99391a72 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -40,7 +40,7 @@ struct CDCHBuild : public dd4hep::xml::tools::VolumeBuilder { double diff_of_squares(double a, double b); void apply_wire_coating(struct wire& w, double outwrap, double halflength, string material); - void PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset, int SL, int ilayer); + void PlaceWires(struct wire& w, double outwrap, double halflength, int SL, int ilayer); void build_layer(DetElement parent, Volume parentVol, dd4hep::SensitiveDetector sens); }; @@ -68,7 +68,7 @@ void CDCHBuild::apply_wire_coating(struct wire& w, double outwrap, double halfle } // deprecated function, only use it for the wires before and after the sensitive zone (mainly guard wires) -void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, int copyNunOffset = 0, int SL = 999, +void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, int SL = 999, int ilayer = 999) { dd4hep::RotationZYX rot(0., 0., w.stereo); @@ -340,13 +340,13 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti lvGwireVol.back().setVisAttributes(description, wirecol); guard_wires.volume = lvGwireVol.back(); - CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, 0, SL, -1); + CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, SL, -1); guard_wires.radius = inGuardRad + inGWradii + extShiftFW; guard_wires.phioffset = layerangle + phi_layer; guard_wires.stereo = -1.0 * epsilonInGwRing; guard_wires.name = string("Gwire_inner_stereominus"); - CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, nInGWire / 2, SL, -1); + CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, SL, -1); drop = radius_layer_0 * dropFactor; radius_layer = radius_layer_0 + drop; @@ -385,7 +385,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti lvFwireVol.back().setVisAttributes(description, wirecol); field_wires_top.volume = lvFwireVol.back(); - CDCHBuild::PlaceWires(field_wires_top, FWireShellThickOut, halflength, 0, SL, -1); + CDCHBuild::PlaceWires(field_wires_top, FWireShellThickOut, halflength, SL, -1); radius_layer_0 += FWradii; @@ -479,7 +479,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti //lvFwireVol.back().setVisAttributes(description, wirecol); ////field_wires_top.volume = lvFwireVol.back(); - //////CDCHBuild::PlaceWires(field_wires_top, FWireShellThickOut, halflength, 0, SL, -1); + //////CDCHBuild::PlaceWires(field_wires_top, FWireShellThickOut, halflength, SL, -1); //radius_layer_0 += FWradii; @@ -803,7 +803,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti lvFwireVol.back().setVisAttributes(description, wirecol); field_wires_bottom.volume = lvFwireVol.back(); - CDCHBuild::PlaceWires(field_wires_bottom, FWireShellThickOut, halflength, 0, SL, -1); + CDCHBuild::PlaceWires(field_wires_bottom, FWireShellThickOut, halflength, SL, -1); //------------------------------------------------------------------------ // Start placing the outer layer of guard wires @@ -843,12 +843,12 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti lvGwireVol.back().setVisAttributes(description, wirecol); guard_wires.volume = lvGwireVol.back(); - CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, 0, SL, -1); + CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, SL, -1); guard_wires.radius = outGuardRad + inGWradii + extShiftFW; guard_wires.phioffset = layerangle + phi_layer; guard_wires.stereo = -1.0 * epsilonOutGwRing; - CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, nOutGWire / 2, SL, -1); + CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, SL, -1); } } From 7fd53d8e07edf149de0eb82825c69bdb59c74d2e Mon Sep 17 00:00:00 2001 From: BrieucF Date: Wed, 26 Jul 2023 11:19:19 +0200 Subject: [PATCH 07/20] [DriftChamber] Fix the number of guard wires --- Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index 99391a72..8a5d4421 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -150,8 +150,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti double outGuardRad = dd4hep::_toDouble("CDCH:outGuardRad"); int nSDeltaWire = dd4hep::_toInt("CDCH:nSDeltaWire"); int nSWire = dd4hep::_toInt("CDCH:nSWire"); - int nInGWire = dd4hep::_toInt("CDCH:nInGWire"); - int nOutGWire = dd4hep::_toInt("CDCH:nOutGWire"); int nStoFWireRatio = dd4hep::_toInt("CDCH:nStoFWireRatio"); int nVerticalFWire = dd4hep::_toInt("CDCH:nVerticalFWire"); int nSuperLayer = dd4hep::_toInt("CDCH:nSuperLayer"); @@ -325,7 +323,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.mother_volume = lvLayerVol.back(); guard_wires.type = "G"; - guard_wires.num = nInGWire; + guard_wires.num = nFWire1; //(#guard wires == # field wires) guard_wires.radius = inGuardRad - inGWradii; guard_wires.phi = 2. * TMath::Pi() / guard_wires.num; guard_wires.phioffset = layerangle; @@ -806,7 +804,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti CDCHBuild::PlaceWires(field_wires_bottom, FWireShellThickOut, halflength, SL, -1); //------------------------------------------------------------------------ - // Start placing the outer layer of guard wires + // Start placing the outer layer of guard wires (#guard wires == # field wires) //------------------------------------------------------------------------ radius_layerIn_0 = radius_layerOut_0; @@ -828,7 +826,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.mother_volume = lvLayerVol.back(); guard_wires.type = "G"; - guard_wires.num = sense_wires.num; // To be checked + guard_wires.num = nFWire1; guard_wires.radius = outGuardRad - inGWradii; guard_wires.phi = 2. * TMath::Pi() / guard_wires.num; guard_wires.phioffset = layerangle; From dba7a6cf8a040dee7a1aeae5591d8c9653455fe0 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Wed, 26 Jul 2023 18:02:30 +0200 Subject: [PATCH 08/20] [DriftChamber] Fix wire materials and dimensions --- .../compact/IDEA_o1_v01/DriftChamber_parameters.xml | 10 ++++++---- Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml index b16804ae..e56332f6 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml @@ -35,15 +35,17 @@ - + + + - + - + - + diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index 8a5d4421..3b33de5e 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -57,7 +57,7 @@ double CDCHBuild::diff_of_squares(double a, double b) { return diff; } -void CDCHBuild::apply_wire_coating(struct wire& w, double outwrap, double halflength, string material = "G4_Au"){ +void CDCHBuild::apply_wire_coating(struct wire& w, double outwrap, double halflength, string material = "Silver"){ dd4hep::Tube WrapTube(w.thickness, w.thickness + 0.5 * outwrap, halflength); dd4hep::Volume WireWrapVol(w.name + "_coating", WrapTube, description.material(material)); dd4hep::Tube TotalWire(0.0, w.thickness + 0.5 * outwrap, halflength); @@ -134,6 +134,8 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti double CarbonEndcapWallThick = dd4hep::_toDouble("CDCH:CarbonEndcapWallThick"); double FWireShellThickIn = dd4hep::_toDouble("CDCH:FWireShellThickIn"); double FWireShellThickOut = dd4hep::_toDouble("CDCH:FWireShellThickOut"); + double centerFWireShellThickIn = dd4hep::_toDouble("CDCH:centerFWireShellThickIn"); + double centerFWireShellThickOut = dd4hep::_toDouble("CDCH:centerFWireShellThickOut"); double SWireShellThickIn = dd4hep::_toDouble("CDCH:SWireShellThickIn"); double SWireShellThickOut = dd4hep::_toDouble("CDCH:SWireShellThickOut"); double CntFWireShellThickIn = dd4hep::_toDouble("CDCH:CntFWireShellThickIn"); @@ -608,7 +610,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti dd4hep::Volume lvSwireVol(lvSwireName, Swire, description.material("G4_W")); lvSwireVol.setVisAttributes(description, wirecol); sense_wires.volume = lvSwireVol; - apply_wire_coating(sense_wires, SWireShellThickOut, halflength); + apply_wire_coating(sense_wires, SWireShellThickOut, halflength, "G4_Au"); //------------------------------------------------------------------------ // Tune the radius and epsilon of the central field wires @@ -629,11 +631,11 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_center.phioffset = layerangle + cellStaggering; field_wires_center.stereo = sign_epsilon * epsilon; field_wires_center.halfalpha = halfalpha; - field_wires_center.thickness = 0.5 * FWireShellThickIn * enlarge; + field_wires_center.thickness = 0.5 * centerFWireShellThickIn * enlarge; field_wires_center.halflength = zlength; field_wires_center.volume = lvFwireVol.back(); field_wires_center.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(ilayer, "_layer%d") + string("_type") + field_wires_center.type + dd4hep::_toString(field_wires_center.stereo, "_stereo%f_center"); - apply_wire_coating(field_wires_center, FWireShellThickOut, halflength); + apply_wire_coating(field_wires_center, centerFWireShellThickOut, halflength); //------------------------------------------------------------------------ From 6a5864b637a8facba3714e7104405b55445a5810 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Wed, 26 Jul 2023 18:06:19 +0200 Subject: [PATCH 09/20] [DriftChamber] Remove useless paramter --- .../compact/IDEA_o1_v01/DriftChamber_parameters.xml | 2 -- Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml index e56332f6..a9a928b4 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml @@ -39,8 +39,6 @@ - - diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index 3b33de5e..0bab87b7 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -138,8 +138,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti double centerFWireShellThickOut = dd4hep::_toDouble("CDCH:centerFWireShellThickOut"); double SWireShellThickIn = dd4hep::_toDouble("CDCH:SWireShellThickIn"); double SWireShellThickOut = dd4hep::_toDouble("CDCH:SWireShellThickOut"); - double CntFWireShellThickIn = dd4hep::_toDouble("CDCH:CntFWireShellThickIn"); - double CntFWireShellThickOut = dd4hep::_toDouble("CDCH:CntFWireShellThickOut"); double InGWireShellThickIn = dd4hep::_toDouble("CDCH:InGWireShellThickIn"); double InGWireShellThickOut = dd4hep::_toDouble("CDCH:InGWireShellThickOut"); double OutGWireShellThickIn = dd4hep::_toDouble("CDCH:InGWireShellThickIn"); @@ -181,8 +179,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti Carbon1OuterWallThick + Carbon2OuterWallThick + CopperOuterWallThick + FoamOuterWallThick; double FWireDiameter = FWireShellThickIn + FWireShellThickOut; double FWradii = 0.5 * FWireDiameter; - double CntFWireDiameter = CntFWireShellThickIn + CntFWireShellThickOut; - double CntFWradii = 0.5 * CntFWireDiameter; double SWireDiameter = SWireShellThickIn + SWireShellThickOut; double SWradii = 0.5 * SWireDiameter; double inGWireDiameter = InGWireShellThickIn + InGWireShellThickOut; @@ -582,7 +578,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti // Reduce zlength to avoid volume extrusions //------------------------------------------------------------------------ - zlength -= sin(epsilon) * CntFWradii; + zlength -= sin(epsilon) * 0.5 * FWireShellThickIn; zlength /= cos(epsilon); //------------------------------------------------------------------------ From f7b4846281db4cb1e057b08815a9c76ed117813e Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 27 Jul 2023 11:34:20 +0200 Subject: [PATCH 10/20] [DriftChamber] Remove unused wire struct member --- Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index 0bab87b7..cd185f6b 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -24,7 +24,6 @@ struct wire double phi; double phioffset; double stereo; - double halfalpha; double thickness; double halflength; dd4hep::Volume volume; @@ -326,7 +325,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.phi = 2. * TMath::Pi() / guard_wires.num; guard_wires.phioffset = layerangle; guard_wires.stereo = epsilonInGwRing; - guard_wires.halfalpha = halfalpha; guard_wires.thickness = 0.5 * InGWireShellThickIn * enlarge; // half the inner thickness as radius of tube guard_wires.halflength = zlength; guard_wires.name = string("Gwire_inner_stereoplus"); @@ -369,7 +367,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_top.phi = 2. * TMath::Pi() /field_wires_top.num;; field_wires_top.phioffset = layerangle + cellStaggering - phi_layer; field_wires_top.stereo = sign_epsilon * epsilon; - field_wires_top.halfalpha = halfalpha; field_wires_top.thickness = 0.5 * FWireShellThickIn * enlarge; field_wires_top.halflength = zlength; @@ -413,7 +410,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti //guard_wires.phi = 2. * TMath::Pi() / guard_wires.num; //guard_wires.phioffset = layerangle; //guard_wires.stereo = epsilonInGwRing; - //guard_wires.halfalpha = halfalpha; //guard_wires.thickness = 0.5 * InGWireShellThickIn * enlarge; // half the inner thickness as radius of tube //guard_wires.halflength = zlength; //guard_wires.name = string("InnerGuardWire") + dd4hep::_toString(guard_wires.stereo, "_stereo%f"); @@ -463,7 +459,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti //field_wires_top.phi = phi_layer1; //field_wires_top.phioffset = layerangle + cellStaggering - phi_layer; //field_wires_top.stereo = sign_epsilon * epsilon; - //field_wires_top.halfalpha = halfalpha; //field_wires_top.thickness = 0.5 * FWireShellThickIn * enlarge; //field_wires_top.halflength = zlength; //field_wires_top.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(-1, "_layer%d") + string("_type") + field_wires_top.type + dd4hep::_toString(field_wires_top.stereo, "_stereo%f_top"); @@ -536,7 +531,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_bottom.phi = phi_layer1; field_wires_bottom.phioffset = layerangle + cellStaggering; field_wires_bottom.stereo = sign_epsilon * epsilon; - field_wires_bottom.halfalpha = halfalpha; field_wires_bottom.thickness = 0.5 * FWireShellThickIn * enlarge; field_wires_bottom.halflength = zlength; field_wires_bottom.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(ilayer, "_layer%d") + string("_type") + field_wires_bottom.type + dd4hep::_toString(field_wires_bottom.stereo, "_stereo%f_bottom"); @@ -591,7 +585,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti sense_wires.phi = phi; sense_wires.phioffset = cellStaggering; sense_wires.stereo = sign_epsilon * epsilon; - sense_wires.halfalpha = halfalpha; sense_wires.thickness = 0.5 * SWireShellThickIn * enlarge; sense_wires.halflength = zlength; sense_wires.name = dd4hep::_toString(SL, "Wire_SL%d") + dd4hep::_toString(ilayer, "_layer%d") + string("_type") + sense_wires.type + dd4hep::_toString(sense_wires.stereo, "_stereo%f"); @@ -626,7 +619,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_center.phi = phi; field_wires_center.phioffset = layerangle + cellStaggering; field_wires_center.stereo = sign_epsilon * epsilon; - field_wires_center.halfalpha = halfalpha; field_wires_center.thickness = 0.5 * centerFWireShellThickIn * enlarge; field_wires_center.halflength = zlength; field_wires_center.volume = lvFwireVol.back(); @@ -677,7 +669,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_top.phi = phi_layer1; field_wires_top.phioffset = layerangle + cellStaggering; field_wires_top.stereo = sign_epsilon * epsilon; - field_wires_top.halfalpha = halfalpha; field_wires_top.thickness = 0.5 * FWireShellThickIn * enlarge; field_wires_top.halflength = zlength; field_wires_top.volume = lvFwireVol.back(); @@ -787,7 +778,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti field_wires_bottom.phi = 2. * TMath::Pi() / field_wires_bottom.num; field_wires_bottom.phioffset = layerangle + cellStaggering + phi_layer; field_wires_bottom.stereo = -1. * sign_epsilon * epsilon; - field_wires_bottom.halfalpha = halfalpha; field_wires_bottom.thickness = 0.5 * FWireShellThickIn * enlarge; field_wires_bottom.halflength = zlength; @@ -829,7 +819,6 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.phi = 2. * TMath::Pi() / guard_wires.num; guard_wires.phioffset = layerangle; guard_wires.stereo = epsilonOutGwRing; - guard_wires.halfalpha = halfalpha; guard_wires.thickness = 0.5 * OutGWireShellThickIn * enlarge; guard_wires.halflength = zlength; guard_wires.name = string("Gwire_outer"); @@ -894,8 +883,10 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4h DetElement CDCH_det = builder.detector; // ( det_name, x_det.id() ); dd4hep::Box CDCH_box("5000/2", "5000/2", "5000/2"); + //dd4hep::Tube CDCH_envelope(dd4hep::_toDouble("CDCH:r0"), dd4hep::_toDouble("CDCH:rOut"), dd4hep::_toDouble("CDCH:zHalfLength")); Volume envelope("lvCDCH", CDCH_box, description.air()); + //Volume envelope("lvCDCH", CDCH_envelope, description.air()); envelope.setVisAttributes(description, "vCDCH:Air"); PlacedVolume pv; From 43d0e18b7595f5678e9256ccd89680abdee85a7e Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 27 Jul 2023 11:36:34 +0200 Subject: [PATCH 11/20] [DriftChamber] Remove G4_Be material since not used and producing warning --- .../compact/IDEA_o1_v01/DriftChamber_materials.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml index 943c8b96..7523bb85 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml @@ -27,12 +27,6 @@ - - - - - - From 595a40ec88cf15f179660418f1d5b8c96bdd7d93 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 27 Jul 2023 13:27:31 +0200 Subject: [PATCH 12/20] [DriftChamber] Better naming for initial/final rings --- Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index cd185f6b..a8478da6 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -210,7 +210,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti // The enlarge parameter is used to see the wires in the rendering //------------------------------------------------------------------------ - double enlarge = 1.; + double enlarge = 50.; //------------------------------------------------------------------------ // Build the inner, outer and endcap walls first @@ -310,7 +310,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti double stereoOut0 = atan(radius_layerOut_0 * (1.0 * dropFactor * epsilonFactor)); dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_layerOut_0 - secure, stereoOut0, halflength); - lvLayerVol.push_back(dd4hep::Volume("lvLayerInit", HypeLayer0, description.material("GasHe_90Isob_10"))); + lvLayerVol.push_back(dd4hep::Volume("hyperboloid_inner_guard_layer", HypeLayer0, description.material("GasHe_90Isob_10"))); lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); epsilonInGwRing = atan(inGuardRad * (1.0 + dropFactor) * epsilonFactor); @@ -353,7 +353,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti epsilonOut = atan(sqrt(pow(radius_layerOut, 2) - pow(radius_layerOut_0, 2)) / halflength); dd4hep::Hyperboloid HypeLayer1(radius_layerIn_0, epsilonIn, radius_layerOut_0, epsilonOut, halflength); - lvLayerVol.push_back(dd4hep::Volume("lvLayer_0", HypeLayer1, description.material("GasHe_90Isob_10"))); + lvLayerVol.push_back(dd4hep::Volume("hyperboloid_first_field_wire_ring", HypeLayer1, description.material("GasHe_90Isob_10"))); lvLayerVol.back().setVisAttributes(description, "vCDCH:Plastic"); zlength = halflength; @@ -764,7 +764,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti epsilonOut = atan(sqrt(diff_of_squares(radius_layerOut, radius_layerOut_0)) / halflength); dd4hep::Hyperboloid HypeLayerOut(radius_layerIn_0, epsilonIn, radius_layerOut_0, epsilonOut, halflength); - lvLayerVol.push_back(dd4hep::Volume("lvLayerOut", HypeLayerOut, description.material("GasHe_90Isob_10"))); + lvLayerVol.push_back(dd4hep::Volume("hyperboloid_last_field_wire_ring", HypeLayerOut, description.material("GasHe_90Isob_10"))); lvLayerVol.back().setVisAttributes(description, "vCDCH:Plastic"); zlength = halflength; @@ -804,7 +804,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti dd4hep::Hyperboloid HypeLayerOutG(radius_layerIn_0, epsilonOut, outer_radius - envelop_Outer_thickness - 0.0001, 0.0, halflength); - lvLayerVol.push_back(dd4hep::Volume("lvLayerOutG", HypeLayerOutG, description.material("GasHe_90Isob_10"))); + lvLayerVol.push_back(dd4hep::Volume("hyperboloid_outer_guard_layer", HypeLayerOutG, description.material("GasHe_90Isob_10"))); lvLayerVol.back().setVisAttributes(description, "vCDCH:Pb"); epsilonOutGwRing = atan(outGuardRad * (1.0 + dropFactor) * epsilonFactor); @@ -821,7 +821,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.stereo = epsilonOutGwRing; guard_wires.thickness = 0.5 * OutGWireShellThickIn * enlarge; guard_wires.halflength = zlength; - guard_wires.name = string("Gwire_outer"); + guard_wires.name = string("Gwire_outer_stereominus"); dd4hep::Tube Gwire(0.0, guard_wires.thickness, halflength); lvGwireVol.push_back(dd4hep::Volume("Gwire_outer", Gwire, description.material("G4_Al"))); @@ -833,6 +833,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.radius = outGuardRad + inGWradii + extShiftFW; guard_wires.phioffset = layerangle + phi_layer; guard_wires.stereo = -1.0 * epsilonOutGwRing; + guard_wires.name = string("Gwire_outer_stereoplus"); CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, SL, -1); } } From 42256eba6a1f14e6520ce95e53dee1d9976d9215 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 27 Jul 2023 19:32:19 +0200 Subject: [PATCH 13/20] [DriftChamber] Set the DD4hep DetElement tree properly --- .../DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index a8478da6..ee62f704 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -110,8 +110,6 @@ void CDCHBuild::PlaceWires(struct wire& w, double outwrap, double halflength, in void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::SensitiveDetector sens_det) { - //dd4hep::PlacedVolume pv; - dd4hep::DetElement CDCHDetector(parent, "CDCH", parent.id()); // ****************************************************** // Loading parameters // ****************************************************** @@ -643,13 +641,12 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti dd4hep::Hyperboloid whole_layer_hyperboloid = dd4hep::Hyperboloid(radius_layerIn_whole_cell, epsilonIn_whole_cell, radius_layerOut_0, epsilonOut, zlength); dd4hep::Volume whole_layer_hyperboloid_volume = dd4hep::Volume(wholeHyperboloidVolumeName, whole_layer_hyperboloid, description.material("GasHe_90Isob_10")); whole_layer_hyperboloid_volume.setVisAttributes(description, gascol); - //whole_layer_hyperboloid_volume.setSensitiveDetector(sens_det); //registerVolume(wholeHyperboloidVolumeName, whole_layer_hyperboloid_volume); - //parentVol.placeVolume(volume(wholeHyperboloidVolumeName)); dd4hep::PlacedVolume whole_layer_hyperboloid_placedVolume; whole_layer_hyperboloid_placedVolume = parentVol.placeVolume(whole_layer_hyperboloid_volume); - CDCHDetector.setPlacement(whole_layer_hyperboloid_placedVolume); whole_layer_hyperboloid_placedVolume.addPhysVolID("superLayer", SL).addPhysVolID("layer", ilayer); + dd4hep::DetElement whole_layer_hyperboloid_detElement(parent, "superLayer_" + dd4hep::_toString(SL) + "_layer_" + dd4hep::_toString(ilayer) + "_hyperboloid", SL * nLayer + ilayer); + whole_layer_hyperboloid_detElement.setPlacement(whole_layer_hyperboloid_placedVolume); //------------------------------------------------------------------------ // Reduce zlength to avoid volume extrusions @@ -719,6 +716,8 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti cellID_volume.setSensitiveDetector(sens_det); cellID_placedvolume = whole_layer_hyperboloid_volume.placeVolume(cellID_volume); cellID_placedvolume.addPhysVolID("phi", phi_index).addPhysVolID("hitorigin", 0).addPhysVolID("stereo", sense_wires.stereo > 0 ? 0 : 1).addPhysVolID("layerInCell", 0); + dd4hep::DetElement cellID_detElement(whole_layer_hyperboloid_detElement, "superLayer_" + dd4hep::_toString(SL) + "_layer_" + dd4hep::_toString(ilayer) + "_phi_" + dd4hep::_toString(phi_index) + "_cellID", phi_index); + cellID_detElement.setPlacement(cellID_placedvolume); // place the wires. The transformation is: apply the stereo angle rotation, translate the wire to the required radius, apply the phi rotation // sense wires in the radial middle of the cell @@ -886,16 +885,9 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4h dd4hep::Box CDCH_box("5000/2", "5000/2", "5000/2"); //dd4hep::Tube CDCH_envelope(dd4hep::_toDouble("CDCH:r0"), dd4hep::_toDouble("CDCH:rOut"), dd4hep::_toDouble("CDCH:zHalfLength")); - Volume envelope("lvCDCH", CDCH_box, description.air()); + dd4hep::Volume envelope("lvCDCH", CDCH_box, description.air()); //Volume envelope("lvCDCH", CDCH_envelope, description.air()); envelope.setVisAttributes(description, "vCDCH:Air"); - PlacedVolume pv; - - dd4hep::printout(dd4hep::DEBUG, "CreateCDCH", "MotherVolume is: %s", envelope.name()); - sens_det.setType("tracker"); - - builder.buildVolumes(e); - builder.placeDaughters(CDCH_det, envelope, e); // ****************************************************** // Build CDCH cable @@ -903,6 +895,12 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4h builder.build_layer(CDCH_det, envelope, sens_det); + dd4hep::printout(dd4hep::DEBUG, "CreateCDCH", "MotherVolume is: %s", envelope.name()); + sens_det.setType("tracker"); + + builder.buildVolumes(e); + builder.placeDaughters(CDCH_det, envelope, e); + // ****************************************************** // Build CDCH cell and beam plug // ****************************************************** @@ -920,6 +918,7 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4h // Place the CDCH in the world // ****************************************************** + PlacedVolume pv; pv = builder.placeDetector(envelope); pv.addPhysVolID("system", x_det.id()); From 57295709cc9edf51830b6b030937b44bab5f535c Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 27 Jul 2023 19:35:08 +0200 Subject: [PATCH 14/20] [DriftChamber] Take detector ID from master xml --- Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml | 2 +- .../DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml index a86cfd80..1c0341ed 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml @@ -13,7 +13,7 @@ --> - + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml index 8a85757e..75678160 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml @@ -28,7 +28,7 @@ - + From 88400b984f94a3aa25eee48b55aea1d29e56c04c Mon Sep 17 00:00:00 2001 From: BrieucF Date: Mon, 31 Jul 2023 13:34:22 +0200 Subject: [PATCH 15/20] [DriftChamber] Fix z extent and detector mother volume --- .../compact/IDEA_o1_v01/DriftChamber_parameters.xml | 3 ++- Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml index a9a928b4..d51e0ab7 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml @@ -17,7 +17,8 @@ - + + diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index ee62f704..1c2f9bb1 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -882,11 +882,9 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4h dd4hep::printout(dd4hep::DEBUG, "CreateCDCH", "Detector name: %s with ID: %s", det_name.c_str(), x_det.id()); DetElement CDCH_det = builder.detector; // ( det_name, x_det.id() ); - dd4hep::Box CDCH_box("5000/2", "5000/2", "5000/2"); - //dd4hep::Tube CDCH_envelope(dd4hep::_toDouble("CDCH:r0"), dd4hep::_toDouble("CDCH:rOut"), dd4hep::_toDouble("CDCH:zHalfLength")); + dd4hep::Tube CDCH_envelope(dd4hep::_toDouble("CDCH:r0"), dd4hep::_toDouble("CDCH:rOut"), dd4hep::_toDouble("CDCH:zHalfLength") + dd4hep::_toDouble("CDCH:GasEndcapWallThick") + dd4hep::_toDouble("CDCH:CopperEndcapWallThick") + dd4hep::_toDouble("CDCH:KaptonEndcapWallThick") + dd4hep::_toDouble("CDCH:CarbonEndcapWallThick")); - dd4hep::Volume envelope("lvCDCH", CDCH_box, description.air()); - //Volume envelope("lvCDCH", CDCH_envelope, description.air()); + dd4hep::Volume envelope("lvCDCH", CDCH_envelope, description.air()); envelope.setVisAttributes(description, "vCDCH:Air"); // ****************************************************** From 795e2ec4ee7f2887f741b3cf88c75c579eba2a8e Mon Sep 17 00:00:00 2001 From: BrieucF Date: Mon, 31 Jul 2023 13:43:18 +0200 Subject: [PATCH 16/20] [DriftChamber] Fix for the guard wire volume --- Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index 1c2f9bb1..0a94ac69 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -334,6 +334,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.volume = lvGwireVol.back(); CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, SL, -1); + guard_wires.volume = lvGwireVol.back(); // needed because applyWireCoating acts on it guard_wires.radius = inGuardRad + inGWradii + extShiftFW; guard_wires.phioffset = layerangle + phi_layer; guard_wires.stereo = -1.0 * epsilonInGwRing; @@ -829,6 +830,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti guard_wires.volume = lvGwireVol.back(); CDCHBuild::PlaceWires(guard_wires, FWireShellThickOut, halflength, SL, -1); + guard_wires.volume = lvGwireVol.back(); // needed because applyWireCoating acts on it guard_wires.radius = outGuardRad + inGWradii + extShiftFW; guard_wires.phioffset = layerangle + phi_layer; guard_wires.stereo = -1.0 * epsilonOutGwRing; From c3ce8343c49867913755a9301cdbe1d7515a7e63 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Mon, 31 Jul 2023 14:45:12 +0200 Subject: [PATCH 17/20] [DriftChamber] Fix warning due to redefinition of variable --- .../DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml index 75678160..6876f580 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectDimensions.xml @@ -203,7 +203,6 @@ - From 0a64048befaf59daed016e29086da4eac54de73f Mon Sep 17 00:00:00 2001 From: Brieuc Francois Date: Wed, 2 Aug 2023 09:10:29 +0200 Subject: [PATCH 18/20] [DriftChamber] Fix mother volume protrusion in the guard layer (#53) --- Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp index 0a94ac69..f14d0083 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp @@ -208,7 +208,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti // The enlarge parameter is used to see the wires in the rendering //------------------------------------------------------------------------ - double enlarge = 50.; + double enlarge = 1.; //------------------------------------------------------------------------ // Build the inner, outer and endcap walls first @@ -284,7 +284,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti throw std::runtime_error("Error: Failed to build CDCH. Please make sure that '(nStoFWireRatio - nVerticalFWire) * (nSWire + SuperLayerIndex * nSDeltaWire)' is always an even number"); phi_layer1 = 2.0 * phi_layer; scaleFactor = (1.0 + TMath::Pi() / num_wire) / (1.0 - TMath::Pi() / num_wire); - dropFactor = (1.0 / cos(halfalpha) - 1.0); + dropFactor = (1.0 / cos(halfalpha) - 1.0); // used to determine the radius of the hyperboloid in z = +- halflength with r_out = r_min + r_min * dropFactor epsilonFactor = sin(halfalpha) / halflength; layerangle = -0.5 * phi; @@ -304,8 +304,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti wirecol = "vCDCH:Wire3"; if (SL == 0) {// SL = 0 is special due to the guard wires and the first field wires that lie outside of the sensitive volume - // FIXME there are some volume extrusion here (wire go outside of the hyperboloid) - double stereoOut0 = atan(radius_layerOut_0 * (1.0 * dropFactor * epsilonFactor)); + double stereoOut0 = atan(sqrt(diff_of_squares((inGuardRad - inGWradii) + (inGuardRad - inGWradii) * dropFactor, inGuardRad - inGWradii)) / halflength); dd4hep::Hyperboloid HypeLayer0(inner_radius_0, 0.0, radius_layerOut_0 - secure, stereoOut0, halflength); lvLayerVol.push_back(dd4hep::Volume("hyperboloid_inner_guard_layer", HypeLayer0, description.material("GasHe_90Isob_10"))); From 468c9c871efec599db29b8ad8224310f22ffe798 Mon Sep 17 00:00:00 2001 From: Brieuc Francois Date: Fri, 4 Aug 2023 09:42:05 +0200 Subject: [PATCH 19/20] [SimpleLayeredCylinder] Enable detectors with a mixture of active and passive layers (#54) --- .../DetCommon/src/SimpleLayeredCylinder_geo.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Detector/DetCommon/src/SimpleLayeredCylinder_geo.cpp b/Detector/DetCommon/src/SimpleLayeredCylinder_geo.cpp index f6f85b9b..a22f30f2 100644 --- a/Detector/DetCommon/src/SimpleLayeredCylinder_geo.cpp +++ b/Detector/DetCommon/src/SimpleLayeredCylinder_geo.cpp @@ -3,19 +3,19 @@ namespace det { /** -Factory for a shape from multiple cylinders. Meant for material approximations. -Expected xml structure: +Factory for a shape from multiple cylinders. +Expected xml structure (the 'sensitive' keyword is optional and default to false): ... - + @author: Joschka Lingemann */ static dd4hep::Ref_t createSimpleLayeredCylinder(dd4hep::Detector& lcdd, dd4hep::xml::Handle_t xmlElement, - dd4hep::SensitiveDetector /*sensDet*/) { + dd4hep::SensitiveDetector sensDet) { dd4hep::xml::DetElement xmlDet = static_cast(xmlElement); std::string name = xmlDet.nameStr(); dd4hep::DetElement detElement(name, xmlDet.id()); @@ -39,6 +39,11 @@ static dd4hep::Ref_t createSimpleLayeredCylinder(dd4hep::Detector& lcdd, if (layer.hasAttr("vis")) { layerVolume.setVisAttributes(lcdd, layerDet.visStr()); } + if (layer.hasAttr("sensitive") && layerDet.isSensitive()) { + dd4hep::xml::Dimension sdType(xmlElement.child(_U(sensitive)));// if called outside of the loop it breaks existing configs without sensitive layers + sensDet.setType(sdType.typeStr()); + layerVolume.setSensitiveDetector(sensDet); + } layer.m_node = layers.next(); } From daab3f96adb38062adc4f7835e8b58c9b0e533fc Mon Sep 17 00:00:00 2001 From: Brieuc Francois Date: Tue, 15 Aug 2023 14:29:44 +0200 Subject: [PATCH 20/20] Dc update (#55) * [DriftChamber] o1_v01 --> o1_v00 to avoid future conflict in k4geo * [DriftChamber] Remove separated file for parameters, set them in the DC compact * [DriftChamber] Remove DriftChamber_materials and put them in the central materials.xml * [DriftChamber] Define the whole envolope as parameter instead of sensitive length --- .../compact/IDEA_o1_v01/DriftChamber.xml | 82 +++- .../IDEA_o1_v01/DriftChamber_materials.xml | 387 ------------------ .../IDEA_o1_v01/DriftChamber_parameters.xml | 88 ---- .../IDEA_o1_v01/FCCee_DectMaster_v01.xml | 2 - .../compact/IDEA_o1_v01/materials.xml | 100 ++++- ...ber_o1_v01.cpp => DriftChamber_o1_v00.cpp} | 9 +- 6 files changed, 170 insertions(+), 498 deletions(-) delete mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml delete mode 100644 Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml rename Detector/DetFCCeeIDEA/src/{DriftChamber_o1_v01.cpp => DriftChamber_o1_v00.cpp} (98%) diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml index 1c0341ed..a9c1046b 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber.xml @@ -1,19 +1,64 @@ - + - Test Drift Chamber stack + Detector description for the IDEA Drift Chamber - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -24,4 +69,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml deleted file mode 100644 index 7523bb85..00000000 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_materials.xml +++ /dev/null @@ -1,387 +0,0 @@ - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml deleted file mode 100644 index d51e0ab7..00000000 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/DriftChamber_parameters.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml index 6bcc1db8..6ddc0b25 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml @@ -19,8 +19,6 @@ - - diff --git a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/materials.xml b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/materials.xml index a899266c..bc8cf170 100644 --- a/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/materials.xml +++ b/Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/materials.xml @@ -225,14 +225,6 @@ - - - - - - - -

@@ -258,4 +250,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v00.cpp similarity index 98% rename from Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp rename to Detector/DetFCCeeIDEA/src/DriftChamber_o1_v00.cpp index f14d0083..7365bbb7 100644 --- a/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v01.cpp +++ b/Detector/DetFCCeeIDEA/src/DriftChamber_o1_v00.cpp @@ -117,7 +117,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti double halfalpha = 0.5 * dd4hep::_toDouble("CDCH:alpha"); double inner_radius = dd4hep::_toDouble("CDCH:r0"); double outer_radius = dd4hep::_toDouble("CDCH:rOut"); - double halflength = dd4hep::_toDouble("CDCH:zHalfLength"); + double zHalfExtentWithServices = dd4hep::_toDouble("CDCH:zHalfExtentWithServices"); double CarbonInnerWallThick = dd4hep::_toDouble("CDCH:CarbonInnerWallThick"); double CopperInnerWallThick = dd4hep::_toDouble("CDCH:CopperInnerWallThick"); double GasInnerWallThick = dd4hep::_toDouble("CDCH:GasInnerWallThick"); @@ -153,6 +153,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti int nLayer = dd4hep::_toInt("CDCH:nLayer"); int nFieldWireShells = dd4hep::_toInt("CDCH:nFieldWireShells"); //bool setWireSensitive = true; // FIXME: add the possibility to have wires sensitive (parameter in the xml) which could be useful for detailed chamber behavior studies, current attempt never lead to a hit in the wire, even with enlarged wires... + double halflength = zHalfExtentWithServices - (GasEndcapWallThick + CopperEndcapWallThick + KaptonEndcapWallThick + CarbonEndcapWallThick); // this will be the sensitive volume z extent double epsilon = 0.0; double phi_layer = 0.0; @@ -245,7 +246,7 @@ void CDCHBuild::build_layer(DetElement parent, Volume parentVol, dd4hep::Sensiti outer_radius - Carbon1OuterWallThick - Carbon2OuterWallThick - FoamOuterWallThick, halflength); dd4hep::Tube OuterWall_Carbon1(outer_radius - Carbon1OuterWallThick - Carbon2OuterWallThick - FoamOuterWallThick, - outer_radius - Carbon2OuterWallThick - FoamOuterWallThick, halflength); + outer_radius - Carbon2OuterWallThick - FoamOuterWallThick, halflength);// FIXME there is an overlap with OuterWall_Carbon1 and the last guard wire layer dd4hep::Tube OuterWall_Foam(outer_radius - Carbon2OuterWallThick - FoamOuterWallThick, outer_radius - Carbon2OuterWallThick, halflength); dd4hep::Tube OuterWall_Carbon2(outer_radius - Carbon2OuterWallThick, outer_radius, halflength); @@ -883,7 +884,7 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4h dd4hep::printout(dd4hep::DEBUG, "CreateCDCH", "Detector name: %s with ID: %s", det_name.c_str(), x_det.id()); DetElement CDCH_det = builder.detector; // ( det_name, x_det.id() ); - dd4hep::Tube CDCH_envelope(dd4hep::_toDouble("CDCH:r0"), dd4hep::_toDouble("CDCH:rOut"), dd4hep::_toDouble("CDCH:zHalfLength") + dd4hep::_toDouble("CDCH:GasEndcapWallThick") + dd4hep::_toDouble("CDCH:CopperEndcapWallThick") + dd4hep::_toDouble("CDCH:KaptonEndcapWallThick") + dd4hep::_toDouble("CDCH:CarbonEndcapWallThick")); + dd4hep::Tube CDCH_envelope(dd4hep::_toDouble("CDCH:r0"), dd4hep::_toDouble("CDCH:rOut"), dd4hep::_toDouble("CDCH:zHalfExtentWithServices")); dd4hep::Volume envelope("lvCDCH", CDCH_envelope, description.air()); envelope.setVisAttributes(description, "vCDCH:Air"); @@ -924,4 +925,4 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& description, xml_h e, dd4h return CDCH_det; } -DECLARE_DETELEMENT(DriftChamber_o1_v01, create_element) +DECLARE_DETELEMENT(DriftChamber_o1_v00, create_element)