From 31cdf8043594a0770ada13f75ee611905d26034c Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 14 Jul 2023 03:59:34 +0200 Subject: [PATCH 1/2] Final step to prepare the V18 version of HGCal geometry which allows non-ero cassette shifts --- .../cms-test-ddhgcalEEV18-algorithm.xml | 42 ++ .../cms-test-ddhgcalHEmixV18-algorithm.xml | 41 ++ .../cms-test-ddhgcalHEsilV18-algorithm.xml | 42 ++ .../data/dd4hep/testHGCalV18.xml | 2 +- .../plugins/DDHGCalMixRotatedCassette.cc | 2 +- .../plugins/DDHGCalSiliconRotatedCassette.cc | 4 +- .../dd4hep/DDHGCalMixRotatedCassette.cc | 676 ++++++++++++++++++ .../dd4hep/DDHGCalSiliconRotatedCassette.cc | 4 +- .../python/testHGCalV18XML_cfi.py | 2 +- .../test/python/dumpHGCalEEDD4hep_cfg.py | 4 +- .../test/python/dumpHGCalHEmixDD4hep_cfg.py | 4 +- .../test/python/dumpHGCalHEsilDD4hep_cfg.py | 4 +- 12 files changed, 814 insertions(+), 13 deletions(-) create mode 100644 Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalEEV18-algorithm.xml create mode 100644 Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalHEmixV18-algorithm.xml create mode 100644 Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalHEsilV18-algorithm.xml create mode 100644 Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedCassette.cc diff --git a/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalEEV18-algorithm.xml b/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalEEV18-algorithm.xml new file mode 100644 index 0000000000000..4fa9fae00159a --- /dev/null +++ b/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalEEV18-algorithm.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalHEmixV18-algorithm.xml b/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalHEmixV18-algorithm.xml new file mode 100644 index 0000000000000..6d4a5b56f77c7 --- /dev/null +++ b/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalHEmixV18-algorithm.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalHEsilV18-algorithm.xml b/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalHEsilV18-algorithm.xml new file mode 100644 index 0000000000000..fc6d1add5ff13 --- /dev/null +++ b/Geometry/HGCalCommonData/data/dd4hep/cms-test-ddhgcalHEsilV18-algorithm.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/HGCalCommonData/data/dd4hep/testHGCalV18.xml b/Geometry/HGCalCommonData/data/dd4hep/testHGCalV18.xml index a412ffc7d2847..fbc9364ea2121 100644 --- a/Geometry/HGCalCommonData/data/dd4hep/testHGCalV18.xml +++ b/Geometry/HGCalCommonData/data/dd4hep/testHGCalV18.xml @@ -42,7 +42,7 @@ - + diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalMixRotatedCassette.cc b/Geometry/HGCalCommonData/plugins/DDHGCalMixRotatedCassette.cc index bde796713c4ca..f2d4a848bf6d2 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalMixRotatedCassette.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalMixRotatedCassette.cc @@ -31,7 +31,7 @@ #include #include -#define EDM_ML_DEBUG +//#define EDM_ML_DEBUG using namespace angle_units::operators; class DDHGCalMixRotatedCassette : public DDAlgorithm { diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalSiliconRotatedCassette.cc b/Geometry/HGCalCommonData/plugins/DDHGCalSiliconRotatedCassette.cc index 7f03dd4caa5cb..2e1e6b5a72149 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalSiliconRotatedCassette.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalSiliconRotatedCassette.cc @@ -32,7 +32,7 @@ #include #include -#define EDM_ML_DEBUG +//#define EDM_ML_DEBUG using namespace angle_units::operators; class DDHGCalSiliconRotatedCassette : public DDAlgorithm { @@ -554,7 +554,6 @@ void DDHGCalSiliconRotatedCassette::positionPassive(const DDLogicalPart& glog, #endif int nr = 2 * v; int nc = -2 * u + v; - int type = HGCalProperty::waferThick(waferProperty_[k]); int part = HGCalProperty::waferPartial(waferProperty_[k]); int orien = HGCalProperty::waferOrient(waferProperty_[k]); int cassette = HGCalProperty::waferCassette(waferProperty_[k]); @@ -566,6 +565,7 @@ void DDHGCalSiliconRotatedCassette::positionPassive(const DDLogicalPart& glog, double xorig = xyoff.first + nc * delx; double yorig = xyoff.second + nr * dy; double angle = std::atan2(yorig, xorig); + int type = HGCalProperty::waferThick(waferProperty_[k]); edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive: layer " << layer + 1 << " cassette " << cassette << " Shift " << cshift.first << ":" << cshift.second << " Original " << xorig << ":" << yorig << ":" << convertRadToDeg(angle) << " Final " << xpos << ":" diff --git a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedCassette.cc b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedCassette.cc new file mode 100644 index 0000000000000..e24ed65e3453e --- /dev/null +++ b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedCassette.cc @@ -0,0 +1,676 @@ +/////////////////////////////////////////////////////////////////////////////// +// File: DDHGCalMixRotatedCassette.cc +// Description: Geometry factory class for HGCal (Mix) adopted for DD4hep +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include + +#include "Geometry/HGCalCommonData/interface/HGCalCell.h" +#include "Geometry/HGCalCommonData/interface/HGCalCassette.h" +#include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" +#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" +#include "Geometry/HGCalCommonData/interface/HGCalProperty.h" +#include "Geometry/HGCalCommonData/interface/HGCalTileIndex.h" +#include "Geometry/HGCalCommonData/interface/HGCalTypes.h" +#include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" +#include "Geometry/HGCalCommonData/interface/HGCalWaferType.h" +#include "DD4hep/DetFactoryHelper.h" +#include "DataFormats/Math/interface/angle_units.h" +#include "DetectorDescription/DDCMS/interface/DDPlugins.h" +#include "DetectorDescription/DDCMS/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +//#define EDM_ML_DEBUG +using namespace angle_units::operators; + +struct HGCalMixRotatedCassette { + HGCalMixRotatedCassette() { throw cms::Exception("HGCalGeom") << "Wrong initialization to HGCalMixRotatedCassette"; } + HGCalMixRotatedCassette(cms::DDParsingContext& ctxt, xml_h e) { + cms::DDNamespace ns(ctxt, e, true); + cms::DDAlgoArguments args(ctxt, e); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Creating an instance"; +#endif + + static constexpr double tol1 = 0.01 * dd4hep::mm; + dd4hep::Volume mother = ns.volume(args.parentName()); + + waferTypes_ = args.value("WaferTypes"); + passiveTypes_ = args.value("PassiveTypes"); + facingTypes_ = args.value("FacingTypes"); + orientationTypes_ = args.value("OrientationTypes"); + partialTypes_ = args.value("PartialTypes"); + placeOffset_ = args.value("PlaceOffset"); + phiBinsScint_ = args.value("NPhiBinScint"); + forFireworks_ = args.value("ForFireWorks"); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette::Number of types of wafers: " << waferTypes_ << " passives: " << passiveTypes_ << " facings: " << facingTypes_ << " Orientations: " << orientationTypes_ << " PartialTypes: " << partialTypes_ << " PlaceOffset: " << placeOffset_ << "; number of cells along phi " << phiBinsScint_ << " forFireworks_: " << forFireworks_; +#endif + firstLayer_ = args.value("FirstLayer"); + absorbMode_ = args.value("AbsorberMode"); + sensitiveMode_ = args.value("SensitiveMode"); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette::First Layer " << firstLayer_ << " and " + << "Absober:Sensitive mode " << absorbMode_ << ":" << sensitiveMode_; +#endif + zMinBlock_ = args.value("zMinBlock"); + waferSize_ = args.value("waferSize"); + waferSepar_ = args.value("SensorSeparation"); + sectors_ = args.value("Sectors"); + cassettes_ = args.value("Cassettes"); + alpha_ = (1._pi) / sectors_; + cosAlpha_ = cos(alpha_); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: zStart " << cms::convert2mm(zMinBlock_) << " wafer width " + << cms::convert2mm(waferSize_) << " separations " << cms::convert2mm(waferSepar_) + << " sectors " << sectors_ << ":" << convertRadToDeg(alpha_) << ":" << cosAlpha_ + << " with " << cassettes_ << " cassettes"; +#endif + slopeB_ = args.value>("SlopeBottom"); + zFrontB_ = args.value>("ZFrontBottom"); + rMinFront_ = args.value>("RMinFront"); + slopeT_ = args.value>("SlopeTop"); + zFrontT_ = args.value>("ZFrontTop"); + rMaxFront_ = args.value>("RMaxFront"); +#ifdef EDM_ML_DEBUG + for (unsigned int i = 0; i < slopeB_.size(); ++i) + edm::LogVerbatim("HGCalGeom") << "Bottom Block [" << i << "] Zmin " << cms::convert2mm(zFrontB_[i]) << " Rmin " + << cms::convert2mm(rMinFront_[i]) << " Slope " << slopeB_[i]; + for (unsigned int i = 0; i < slopeT_.size(); ++i) + edm::LogVerbatim("HGCalGeom") << "Top Block [" << i << "] Zmin " << cms::convert2mm(zFrontT_[i]) << " Rmax " + << cms::convert2mm(rMaxFront_[i]) << " Slope " << slopeT_[i]; +#endif + + waferFull_ = args.value>("WaferNamesFull"); + waferPart_ = args.value>("WaferNamesPartial"); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << waferFull_.size() << " full and " + << waferPart_.size() << " partial modules\nDDHGCalMixRotatedCassette:Full Modules:"; + unsigned int i1max = static_cast(waferFull_.size()); + for (unsigned int i1 = 0; i1 < i1max; i1 += 2) { + std::ostringstream st1; + unsigned int i2 = std::min((i1 + 2), i1max); + for (unsigned int i = i1; i < i2; ++i) + st1 << " [" << i << "] " << waferFull_[i]; + edm::LogVerbatim("HGCalGeom") << st1.str(); + } + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Partial Modules:"; + i1max = static_cast(waferPart_.size()); + for (unsigned int i1 = 0; i1 < i1max; i1 += 2) { + std::ostringstream st1; + unsigned int i2 = std::min((i1 + 2), i1max); + for (unsigned int i = i1; i < i2; ++i) + st1 << " [" << i << "] " << waferPart_[i]; + edm::LogVerbatim("HGCalGeom") << st1.str(); + } +#endif + passiveFull_ = args.value>("PassiveNamesFull"); + passivePart_ = args.value>("PassiveNamesPartial"); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << passiveFull_.size() << " full and " + << passivePart_.size() << " partial passive modules"; + i1max = static_cast(passiveFull_.size()); + for (unsigned int i1 = 0; i1 < i1max; i1 += 2) { + std::ostringstream st1; + unsigned int i2 = std::min((i1 + 2), i1max); + for (unsigned int i = i1; i < i2; ++i) + st1 << " [" << i << "] " << passiveFull_[i]; + edm::LogVerbatim("HGCalGeom") << st1.str(); + } + edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Partial Modules:"; + i1max = static_cast(passivePart_.size()); + for (unsigned int i1 = 0; i1 < i1max; i1 += 2) { + std::ostringstream st1; + unsigned int i2 = std::min((i1 + 2), i1max); + for (unsigned int i = i1; i < i2; ++i) + st1 << " [" << i << "] " << passivePart_[i]; + edm::LogVerbatim("HGCalGeom") << st1.str(); + } +#endif + + materials_ = args.value>("MaterialNames"); + names_ = args.value>("VolumeNames"); + thick_ = args.value>("Thickness"); + copyNumber_.resize(materials_.size(), 1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << materials_.size() << " types of volumes"; + for (unsigned int i = 0; i < names_.size(); ++i) + edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] << " of thickness " + << cms::convert2mm(thick_[i]) << " filled with " << materials_[i] + << " first copy number " << copyNumber_[i]; +#endif + layers_ = args.value>("Layers"); + layerThick_ = args.value>("LayerThick"); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks"; + for (unsigned int i = 0; i < layers_.size(); ++i) + edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << cms::convert2mm(layerThick_[i]) + << " with " << layers_[i] << " layers"; +#endif + layerType_ = args.value>("LayerType"); + layerSense_ = args.value>("LayerSense"); + layerOrient_ = args.value>("LayerTypes"); + for (unsigned int k = 0; k < layerOrient_.size(); ++k) + layerOrient_[k] = HGCalTypes::layerType(layerOrient_[k]); +#ifdef EDM_ML_DEBUG + for (unsigned int i = 0; i < layerOrient_.size(); ++i) + edm::LogVerbatim("HGCalGeom") << "LayerOrient [" << i << "] " << layerOrient_[i]; +#endif + if (firstLayer_ > 0) { + for (unsigned int i = 0; i < layerType_.size(); ++i) { + if (layerSense_[i] != 0) { + int ii = layerType_[i]; + copyNumber_[ii] = firstLayer_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " << i << ":" << ii << " with " + << materials_[ii] << " changed to " << copyNumber_[ii]; +#endif + } + } + } else { + firstLayer_ = 1; + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers"; + for (unsigned int i = 0; i < layerType_.size(); ++i) + edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class " + << layerSense_[i]; +#endif + materialTop_ = args.value>("TopMaterialNames"); + namesTop_ = args.value>("TopVolumeNames"); + layerThickTop_ = args.value>("TopLayerThickness"); + layerTypeTop_ = args.value>("TopLayerType"); + copyNumberTop_.resize(materialTop_.size(), firstLayer_); + coverTypeTop_ = args.value("TopCoverLayerType"); + copyNumberCoverTop_ = firstLayer_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << materialTop_.size() << " types of volumes in the top part; cover Type " << coverTypeTop_ << " with initial copy number " << copyNumberCoverTop_; + for (unsigned int i = 0; i < materialTop_.size(); ++i) + edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesTop_[i] << " of thickness " + << cms::convert2mm(layerThickTop_[i]) << " filled with " << materialTop_[i] + << " first copy number " << copyNumberTop_[i]; + edm::LogVerbatim("HGCalGeom") << "There are " << layerTypeTop_.size() << " layers in the top part"; + for (unsigned int i = 0; i < layerTypeTop_.size(); ++i) + edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerTypeTop_[i]; +#endif + waferIndex_ = args.value>("WaferIndex"); + waferProperty_ = args.value>("WaferProperties"); + waferLayerStart_ = args.value>("WaferLayerStart"); + cassetteShift_ = args.value>("CassetteShift"); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "waferProperties with " << waferIndex_.size() << " entries in " + << waferLayerStart_.size() << " layers"; + for (unsigned int k = 0; k < waferLayerStart_.size(); ++k) + edm::LogVerbatim("HGCalGeom") << "LayerStart[" << k << "] " << waferLayerStart_[k]; + for (unsigned int k = 0; k < waferIndex_.size(); ++k) + edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << waferIndex_[k] << " (" + << HGCalWaferIndex::waferLayer(waferIndex_[k]) << ", " + << HGCalWaferIndex::waferU(waferIndex_[k]) << ", " + << HGCalWaferIndex::waferV(waferIndex_[k]) << ") : (" + << HGCalProperty::waferThick(waferProperty_[k]) << ":" + << HGCalProperty::waferPartial(waferProperty_[k]) << ":" + << HGCalProperty::waferOrient(waferProperty_[k]) << ")"; + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << cassetteShift_.size() + << " elements for cassette shifts"; + unsigned int j1max = cassetteShift_.size(); + for (unsigned int j1 = 0; j1 < j1max; j1 += 6) { + std::ostringstream st1; + unsigned int j2 = std::min((j1 + 6), j1max); + for (unsigned int j = j1; j < j2; ++j) + st1 << " [" << j << "] " << std::setw(9) << cassetteShift_[j]; + edm::LogVerbatim("HGCalGeom") << st1.str(); + } +#endif + tileRMin_ = args.value>("TileRMin"); + tileRMax_ = args.value>("TileRMax"); + tileIndex_ = args.value>("TileLayerRings"); + tilePhis_ = args.value>("TilePhiRange"); + tileLayerStart_ = args.value>("TileLayerStart"); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette:: with " << tileRMin_.size() << " rings"; + for (unsigned int k = 0; k < tileRMin_.size(); ++k) + edm::LogVerbatim("HGCalGeom") << "Ring[" << k << "] " << cms::convert2mm(tileRMin_[k]) << " : " + << cms::convert2mm(tileRMax_[k]); + edm::LogVerbatim("HGCalGeom") << "TileProperties with " << tileIndex_.size() << " entries in " + << tileLayerStart_.size() << " layers"; + for (unsigned int k = 0; k < tileLayerStart_.size(); ++k) + edm::LogVerbatim("HGCalGeom") << "LayerStart[" << k << "] " << tileLayerStart_[k]; + for (unsigned int k = 0; k < tileIndex_.size(); ++k) + edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << tileIndex_[k] << " (" + << "Layer " << std::get<0>(HGCalTileIndex::tileUnpack(tileIndex_[k])) << " Ring " + << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[k])) << ":" + << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[k])) << ") Phi " + << std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[k])) << ":" + << std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[k])); +#endif + cassette_.setParameter(cassettes_, cassetteShift_); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: NameSpace " << ns.name(); + + edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalMixRotatedCassette..."; + copies_.clear(); +#endif + + double zi(zMinBlock_); + int laymin(0); + for (unsigned int i = 0; i < layers_.size(); i++) { + double zo = zi + layerThick_[i]; + double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_); + int laymax = laymin + layers_[i]; + double zz = zi; + double thickTot(0); + for (int ly = laymin; ly < laymax; ++ly) { + int ii = layerType_[ly]; + int copy = copyNumber_[ii]; + double hthick = 0.5 * thick_[ii]; + double rinB = HGCalGeomTools::radius(zo, zFrontB_, rMinFront_, slopeB_); + zz += hthick; + thickTot += thick_[ii]; + + std::string name = names_[ii] + std::to_string(copy); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << ly << ":" << ii << " Front " + << cms::convert2mm(zi) << ", " << cms::convert2mm(routF) << " Back " + << cms::convert2mm(zo) << ", " << cms::convert2mm(rinB) + << " superlayer thickness " << cms::convert2mm(layerThick_[i]); +#endif + + dd4hep::Material matter = ns.material(materials_[ii]); + dd4hep::Volume glog; + + if (layerSense_[ly] == 0) { + std::vector pgonZ, pgonRin, pgonRout; + double rmax = + (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, rMaxFront_, slopeT_)) * cosAlpha_) - tol1; + HGCalGeomTools::radius(zz - hthick, + zz + hthick, + zFrontB_, + rMinFront_, + slopeB_, + zFrontT_, + rMaxFront_, + slopeT_, + -layerSense_[ly], + pgonZ, + pgonRin, + pgonRout); + for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) { + pgonZ[isec] -= zz; + if (layerSense_[ly] == 0 || absorbMode_ == 0) + pgonRout[isec] = rmax; + else + pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1; + } + + dd4hep::Solid solid = dd4hep::Polyhedra(sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout); + ns.addSolidNS(ns.prepend(name), solid); + glog = dd4hep::Volume(solid.name(), solid, matter); + ns.addVolumeNS(glog); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << solid.name() << " polyhedra of " << sectors_ + << " sectors covering " << convertRadToDeg(-alpha_) << ":" + << convertRadToDeg(-alpha_ + 2._pi) << " with " << pgonZ.size() << " sections"; + for (unsigned int k = 0; k < pgonZ.size(); ++k) + edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << cms::convert2mm(pgonZ[k]) << " R " + << cms::convert2mm(pgonRin[k]) << ":" << cms::convert2mm(pgonRout[k]); +#endif + } else { + int mode = (layerSense_[ly] > 0) ? sensitiveMode_ : absorbMode_; + double rins = (mode < 1) ? rinB : HGCalGeomTools::radius(zz + hthick, zFrontB_, rMinFront_, slopeB_); + double routs = (mode < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_); + dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi); + ns.addSolidNS(ns.prepend(name), solid); + glog = dd4hep::Volume(solid.name(), solid, matter); + ns.addVolumeNS(glog); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << solid.name() << " Tubs made of " + << matter.name() << " of dimensions " << cms::convert2mm(rinB) << ":" + << cms::convert2mm(rins) << ", " << cms::convert2mm(routF) << ":" + << cms::convert2mm(routs) << ", " << cms::convert2mm(hthick) + << ", 0.0, 360.0 and positioned in: " << glog.name() << " number " << copy; +#endif + positionMix(ctxt, e, glog, name, copy, thick_[ii], matter, -layerSense_[ly]); + } + + dd4hep::Position r1(0, 0, zz); + mother.placeVolume(glog, copy, r1); + ++copyNumber_[ii]; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << glog.name() << " number " << copy + << " positioned in " << mother.name() << " at (0,0," << cms::convert2mm(zz) + << ") with no rotation"; +#endif + zz += hthick; + } // End of loop over layers in a block + zi = zo; + laymin = laymax; + if (std::abs(thickTot - layerThick_[i]) > tol2_) { + if (thickTot > layerThick_[i]) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << cms::convert2mm(layerThick_[i]) + << " is smaller than " << cms::convert2mm(thickTot) + << ": thickness of all its components **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << cms::convert2mm(layerThick_[i]) + << " does not match with " << cms::convert2mm(thickTot) << " of the components"; + } + } + } // End of loop over blocks + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << copies_.size() << " different wafer copy numbers"; + int k(0); + for (std::unordered_set::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++k) { + edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr); + } + copies_.clear(); + edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalMixRotatedCassette construction..."; +#endif + } + + void positionMix(cms::DDParsingContext& ctxt, + xml_h e, + const dd4hep::Volume& glog, + const std::string& nameM, + int copyM, + double thick, + const dd4hep::Material& matter, + int absType) { + cms::DDNamespace ns(ctxt, e, true); + + // Make the top part first + for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) { + int ii = layerTypeTop_[ly]; + copyNumberTop_[ii] = copyM; + } + double hthick = 0.5 * thick; + double dphi = (2._pi) / phiBinsScint_; + double thickTot(0), zpos(-hthick); + if (absType < 0) { + for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) { + int ii = layerTypeTop_[ly]; + int copy = copyNumberTop_[ii]; + int layer = copy - firstLayer_; + double hthickl = 0.5 * layerThickTop_[ii]; + thickTot += layerThickTop_[ii]; + zpos += hthickl; + dd4hep::Material matter1 = ns.material(materialTop_[ii]); + unsigned int k = 0; + int firstTile = tileLayerStart_[layer]; + int lastTile = ((layer + 1 < static_cast(tileLayerStart_.size())) ? tileLayerStart_[layer + 1] : static_cast(tileIndex_.size())); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << ly << ":" << ii << " Copy " << copy << " Tiles " << firstTile << ":" << lastTile; +#endif + for (int ti = firstTile; ti < lastTile; ++ti) { + double r1 = tileRMin_[std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; + double r2 = tileRMax_[std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; + int cassette = std::get<0>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + int fimin = std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + int fimax = std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + double phi1 = dphi * (fimin - 1); + double phi2 = (forFireworks_ == 1) ? (dphi * (fimax - fimin + 1)) : (dphi * fimax); + auto cshift = cassette_.getShift(layer + 1, 1, cassette); +#ifdef EDM_ML_DEBUG + int cassette0 = HGCalCassette::cassetteType(2, 1, cassette); // + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << copy << ":" << (layer + 1) << " iR " << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << ":" << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << " R " << cms::convert2mm(r1) << ":" << cms::convert2mm(r2) << " Thick " << cms::convert2mm((2.0 * hthickl)) << " phi " << fimin << ":" << fimax << ":" << convertRadToDeg(phi1) << ":" << convertRadToDeg(phi2) << " cassette " << cassette << ":" << cassette0 << " Shift " << cms::convert2mm(cshift.first) << ":" << cms::convert2mm(cshift.second); +#endif + std::string name = namesTop_[ii] + "L" + std::to_string(copy) + "F" + std::to_string(k); + ++k; + dd4hep::Solid solid = dd4hep::Tube(r1, r2, hthickl, phi1, phi2); + ns.addSolidNS(ns.prepend(name), solid); + dd4hep::Volume glog1 = dd4hep::Volume(solid.name(), solid, matter1); + ns.addVolumeNS(glog1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << glog1.name() << " Tubs made of " << materialTop_[ii] << " of dimensions " << cms::convert2mm(r1) << ", " << cms::convert2mm(r2) << ", " << cms::convert2mm(hthickl) << ", " << convertRadToDeg(phi1) << ", " << convertRadToDeg(phi2); +#endif + dd4hep::Position tran(-cshift.first, cshift.second, zpos); + glog.placeVolume(glog1, copy, tran); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Position " << glog1.name() << " number " << copy << " in " << glog.name() << " at (" << cms::convert2mm(cshift.first) << ", " << cms::convert2mm(cshift.second) << ", " << cms::convert2mm(zpos) << ") with no rotation"; +#endif + } + ++copyNumberTop_[ii]; + zpos += hthickl; + } + if (std::abs(thickTot - thick) > tol2_) { + if (thickTot > thick) { + edm::LogError("HGCalGeom") << "DDHGCalMixRotatedCassette: Thickness of the partition " << cms::convert2mm(thick) << " is smaller than " << cms::convert2mm(thickTot) << ": thickness of all its components in the top part **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "DDHGCalMixRotatedCassette: Thickness of the partition " << cms::convert2mm(thick) << " does not match with " << cms::convert2mm(thickTot) << " of the components in top part"; + } + } + } else { + int ii = coverTypeTop_; + int copy = copyNumberCoverTop_; + int layer = copy - firstLayer_; + double hthickl = 0.5 * layerThickTop_[ii]; + zpos += hthickl; + dd4hep::Material matter1 = ns.material(materialTop_[ii]); + unsigned int k = 0; + int firstTile = tileLayerStart_[layer]; + int lastTile = ((layer + 1 < static_cast(tileLayerStart_.size())) ? tileLayerStart_[layer + 1] : static_cast(tileIndex_.size())); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << layer << ":" << ii << " Copy " << copy << " Tiles " << firstTile << ":" << lastTile; +#endif + for (int ti = firstTile; ti < lastTile; ++ti) { + double r1 = tileRMin_[std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; + double r2 = tileRMax_[std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; + int cassette = std::get<0>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + int fimin = std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + int fimax = std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + double phi1 = dphi * (fimin - 1); + double phi2 = (forFireworks_ == 1) ? (dphi * (fimax - fimin + 1)) : (dphi * fimax); + auto cshift = cassette_.getShift(layer + 1, 1, cassette); +#ifdef EDM_ML_DEBUG + int cassette0 = HGCalCassette::cassetteType(2, 1, cassette); // + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << copy << ":" << (layer + 1) << " iR " << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << ":" << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << " R " << cms::convert2mm(r1) << ":" << cms::convert2mm(r2) << " Thick " << cms::convert2mm(2.0 * hthickl) << " phi " << fimin << ":" << fimax << ":" << convertRadToDeg(phi1) << ":" << convertRadToDeg(phi2) << " cassette " << cassette << ":" << cassette0 << " Shift " << cms::convert2mm(cshift.first) << ":" << cms::convert2mm(cshift.second); +#endif + std::string name = namesTop_[ii] + "L" + std::to_string(copy) + "F" + std::to_string(k); + ++k; + dd4hep::Solid solid = dd4hep::Tube(r1, r2, hthickl, phi1, phi2); + ns.addSolidNS(ns.prepend(name), solid); + dd4hep::Volume glog1 = dd4hep::Volume(solid.name(), solid, matter1); + ns.addVolumeNS(glog1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << glog1.name() << " Tubs made of " << matter1.name() << " of dimensions " << cms::convert2mm(r1) << ", " << cms::convert2mm(r2) << ", " << cms::convert2mm(hthickl) << ", " << convertRadToDeg(phi1) << ", " << convertRadToDeg(phi2); +#endif + dd4hep::Position tran(-cshift.first, cshift.second, zpos); + glog.placeVolume(glog1, copy, tran); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Position " << glog1.name() << " number " << copy << " in " << glog.name() << " at (" << cms::convert2mm(cshift.first) << ", " << cms::convert2mm(cshift.second) << ", " << cms::convert2mm(zpos) << ") with no rotation"; +#endif + } + ++copyNumberCoverTop_; + zpos += hthickl; + } + + // Make the bottom part next + int layer = (copyM - firstLayer_); + static const double sqrt3 = std::sqrt(3.0); + int layercenter = layerOrient_[layer]; + int layertype = HGCalTypes::layerFrontBack(layerOrient_[layer]); + int firstWafer = waferLayerStart_[layer]; + int lastWafer = ((layer + 1 < static_cast(waferLayerStart_.size())) ? waferLayerStart_[layer + 1] + : static_cast(waferIndex_.size())); + double delx = 0.5 * (waferSize_ + waferSepar_); + double dely = 2.0 * delx / sqrt3; + double dy = 0.75 * dely; + const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_)); +#ifdef EDM_ML_DEBUG + int ium(0), ivm(0), kount(0); + std::vector ntype(3, 0); + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << glog.name() << " r " << cms::convert2mm(delx) + << " R " << cms::convert2mm(dely) << " dy " << cms::convert2mm(dy) << " Shift " + << cms::convert2mm(xyoff.first) << ":" << cms::convert2mm(xyoff.second) + << " WaferSize " << cms::convert2mm((waferSize_ + waferSepar_)) << " index " + << firstWafer << ":" << (lastWafer - 1) << " Copy " << copyM << ":" << layer; +#endif + for (int k = firstWafer; k < lastWafer; ++k) { + int u = HGCalWaferIndex::waferU(waferIndex_[k]); + int v = HGCalWaferIndex::waferV(waferIndex_[k]); +#ifdef EDM_ML_DEBUG + int iu = std::abs(u); + int iv = std::abs(v); +#endif + int nr = 2 * v; + int nc = -2 * u + v; + int type = HGCalProperty::waferThick(waferProperty_[k]); + int part = HGCalProperty::waferPartial(waferProperty_[k]); + int orien = HGCalProperty::waferOrient(waferProperty_[k]); + int cassette = HGCalProperty::waferCassette(waferProperty_[k]); + int place = HGCalCell::cellPlacementIndex(1, layertype, orien); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") + << "DDHGCalMixRotatedCassette::index:Property:layertype:type:part:orien:cassette:place:offsets:ind " << k << ":" + << waferProperty_[k] << ":" << layertype << ":" << type << ":" << part << ":" << orien << ":" << cassette + << ":" << place; +#endif + auto cshift = cassette_.getShift(layer + 1, -1, cassette); + double xpos = xyoff.first - cshift.first + nc * delx; + double ypos = xyoff.second + cshift.second + nr * dy; +#ifdef EDM_ML_DEBUG + double xorig = xyoff.first + nc * delx; + double yorig = xyoff.second + nr * dy; + double angle = std::atan2(yorig, xorig); + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette::Wafer: layer " << layer + 1 << " cassette " << cassette << " Shift " << cms::convert2mm(cshift.first) << ":" << cms::convert2mm(cshift.second) << " Original " << cms::convert2mm(xorig) << ":" << cms::convert2mm(yorig) << ":" << convertRadToDeg(angle) << " Final " << cms::convert2mm(xpos) << ":" << cms::convert2mm(ypos); +#endif + std::string wafer; + int i(999); + if (absType < 0) { + if (part == HGCalTypes::WaferFull) { + i = type * facingTypes_ * orientationTypes_ + place - placeOffset_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << " FullWafer type:place:ind " << type << ":" << place << ":" << i << ":" << waferFull_.size(); +#endif + wafer = waferFull_[i]; + } else { + int partoffset = (part >= HGCalTypes::WaferHDTop) ? HGCalTypes::WaferPartHDOffset : HGCalTypes::WaferPartLDOffset; + i = (part - partoffset) * facingTypes_ * orientationTypes_ + HGCalTypes::WaferTypeOffset[type] * facingTypes_ * orientationTypes_ + place - placeOffset_; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << " layertype:type:part:orien:cassette:place:offsets:ind " << layertype << ":" << type << ":" << part << ":" << orien << ":" << cassette << ":" << place << ":" << partoffset << ":" << HGCalTypes::WaferTypeOffset[type] << ":" << i << ":" << waferPart_.size(); +#endif + wafer = waferPart_[i]; + } + } else { + type = absType; + if (part == HGCalTypes::WaferFull) { + i = absType - 1; + wafer = passiveFull_[i]; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:offsets:ind " << layertype << ":" << absType << ":" << part << ":" << orien << ":" << cassette << ":" << ":" << partialTypes_ << ":" << orientationTypes_ << " passive " << i << ":" << wafer; +#endif + } else { + int partoffset = (part >= HGCalTypes::WaferHDTop) ? HGCalTypes::WaferPartHDOffset : (HGCalTypes::WaferPartLDOffset - HGCalTypes::WaferTypeOffset[1]); + i = (part - partoffset) * facingTypes_ * orientationTypes_ + (absType - 1) * facingTypes_ * orientationTypes_ * partialTypes_ + place - placeOffset_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:3Types:offset:ind " << layertype << ":"<< absType << ":" << part << ":" << orien << ":" << cassette << ":" << partialTypes_ << ":" << facingTypes_ << ":" << orientationTypes_ << ":" << partoffset << ":" << i << ":" << passivePart_.size(); +#endif + wafer = passivePart_[i]; + } + } + + int copy = HGCalTypes::packTypeUV(type, u, v); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << " DDHGCalMixRotatedCassette: Layer " << HGCalWaferIndex::waferLayer(waferIndex_[k]) + << " Wafer " << wafer << " number " << copy << " type :part:orien:ind " << type + << ":" << part << ":" << orien << ":" << i << " layer:u:v " << (layer + firstLayer_) + << ":" << u << ":" << v; + if (iu > ium) + ium = iu; + if (iv > ivm) + ivm = iv; + kount++; + if (copies_.count(copy) == 0) + copies_.insert(copy); +#endif + dd4hep::Position tran(xpos, ypos, 0.0); + glog.placeVolume(ns.volume(wafer), copy, tran); +#ifdef EDM_ML_DEBUG + ++ntype[type]; + edm::LogVerbatim("HGCalGeom") << " DDHGCalMixRotatedCassette: " << wafer << " number " << copy << " type " + << layertype << ":" << type << " positioned in " << glog.name() << " at (" + << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos) << ",0) with no rotation"; +#endif + } + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Maximum # of u " << ium << " # of v " << ivm << " and " + << kount << " wafers (" << ntype[0] << ":" << ntype[1] << ":" << ntype[2] << ") for " + << glog.name(); +#endif + } + + //Required data members to cache the values from XML file + HGCalGeomTools geomTools_; + HGCalCassette cassette_; + + static constexpr double tol2_ = 0.00001 * dd4hep::mm; + + int waferTypes_; // Number of wafer types + int passiveTypes_; // Number of passive types + int facingTypes_; // Types of facings of modules toward IP + int orientationTypes_; // Number of partial wafer orienations + int partialTypes_; // Number of partial types + int placeOffset_; // Offset for placement + int phiBinsScint_; // Maximum number of cells along phi + int forFireworks_; // Needed for Fireworks(1)/Geant4(0) + int firstLayer_; // Copy # of the first sensitive layer + int absorbMode_; // Absorber mode + int sensitiveMode_; // Sensitive mode + double zMinBlock_; // Starting z-value of the block + double waferSize_; // Width of the wafer + double waferSepar_; // Sensor separation + int sectors_; // Sectors + int cassettes_; // Cassettes + std::vector slopeB_; // Slope at the lower R + std::vector zFrontB_; // Starting Z values for the slopes + std::vector rMinFront_; // Corresponding rMin's + std::vector slopeT_; // Slopes at the larger R + std::vector zFrontT_; // Starting Z values for the slopes + std::vector rMaxFront_; // Corresponding rMax's + std::vector waferFull_; // Names of full wafer modules + std::vector waferPart_; // Names of partial wafer modules + std::vector passiveFull_; // Names of full passive modules + std::vector passivePart_; // Names of partial passive modules + std::vector materials_; // Materials + std::vector names_; // Names + std::vector thick_; // Thickness of the material + std::vector copyNumber_; // Initial copy numbers + std::vector layers_; // Number of layers in a section + std::vector layerThick_; // Thickness of each section + std::vector layerType_; // Type of the layer + std::vector layerSense_; // Content of a layer (sensitive?) + std::vector materialTop_; // Materials of top layers + std::vector namesTop_; // Names of top layers + std::vector layerThickTop_; // Thickness of the top sections + std::vector layerTypeTop_; // Type of the Top layer + std::vector copyNumberTop_; // Initial copy numbers (top section) + int coverTypeTop_; // Type of the Top layer cover + int copyNumberCoverTop_; // Initial copy number of top cover + std::vector layerOrient_; // Layer orientation for the silicon component + std::vector waferIndex_; // Wafer index for the types + std::vector waferProperty_; // Wafer property + std::vector waferLayerStart_; // Start index of wafers in each layer + std::vector cassetteShift_; // Shifts of the cassetes + std::vector tileRMin_; // Minimum radius of each ring + std::vector tileRMax_; // Maximum radius of each ring + std::vector tileIndex_; // Index of tile (layer/start|end ring) + std::vector tilePhis_; // Tile phi range for each index + std::vector tileLayerStart_; // Start index of tiles in each layer + std::unordered_set copies_; // List of copy #'s + double alpha_, cosAlpha_; +}; + +static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) { + HGCalMixRotatedCassette mixRotatedCassetteAlgo(ctxt, e); + return cms::s_executed; +} + +DECLARE_DDCMS_DETELEMENT(DDCMS_hgcal_DDHGCalMixRotatedCassette, algorithm) diff --git a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalSiliconRotatedCassette.cc b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalSiliconRotatedCassette.cc index 04b72b4d91f92..64b3345f80a5b 100644 --- a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalSiliconRotatedCassette.cc +++ b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalSiliconRotatedCassette.cc @@ -24,7 +24,7 @@ #include "DetectorDescription/DDCMS/interface/DDutils.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#define EDM_ML_DEBUG +//#define EDM_ML_DEBUG using namespace angle_units::operators; struct HGCalSiliconRotatedCassette { @@ -483,7 +483,6 @@ struct HGCalSiliconRotatedCassette { #endif int nr = 2 * v; int nc = -2 * u + v; - int type = HGCalProperty::waferThick(waferProperty_[k]); int part = HGCalProperty::waferPartial(waferProperty_[k]); int orien = HGCalProperty::waferOrient(waferProperty_[k]); int cassette = HGCalProperty::waferCassette(waferProperty_[k]); @@ -495,6 +494,7 @@ struct HGCalSiliconRotatedCassette { double xorig = xyoff.first + nc * delx; double yorig = xyoff.second + nr * dy; double angle = std::atan2(yorig, xorig); + int type = HGCalProperty::waferThick(waferProperty_[k]); edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive: layer " << layer + 1 << " cassette " << cassette << " Shift " << cms::convert2mm(cshift.first) << ":" << cms::convert2mm(cshift.second) << " Original " << cms::convert2mm(xorig) << ":" diff --git a/Geometry/HGCalCommonData/python/testHGCalV18XML_cfi.py b/Geometry/HGCalCommonData/python/testHGCalV18XML_cfi.py index af7d47b2d9042..48f7821df6ee1 100644 --- a/Geometry/HGCalCommonData/python/testHGCalV18XML_cfi.py +++ b/Geometry/HGCalCommonData/python/testHGCalV18XML_cfi.py @@ -62,7 +62,7 @@ 'Geometry/HGCalCommonData/data/hgcalPassive/v18/hgcalPassive.xml', 'Geometry/HGCalCommonData/data/hgcalEE/v18/hgcalEE.xml', 'Geometry/HGCalCommonData/data/hgcalHEsil/v18/hgcalHEsil.xml', - 'Geometry/HGCalCommonData/data/hgcalHEmix/v17/hgcalHEmix.xml', + 'Geometry/HGCalCommonData/data/hgcalHEmix/v18/hgcalHEmix.xml', 'Geometry/HGCalCommonData/data/hgcalCons/v18/hgcalCons.xml', 'Geometry/HGCalCommonData/data/hgcalConsData/v17/hgcalConsData.xml', 'Geometry/MuonCommonData/data/mbCommon/2021/v1/mbCommon.xml', diff --git a/Geometry/HGCalCommonData/test/python/dumpHGCalEEDD4hep_cfg.py b/Geometry/HGCalCommonData/test/python/dumpHGCalEEDD4hep_cfg.py index 4560c4000dd4a..98722acbbfab4 100644 --- a/Geometry/HGCalCommonData/test/python/dumpHGCalEEDD4hep_cfg.py +++ b/Geometry/HGCalCommonData/test/python/dumpHGCalEEDD4hep_cfg.py @@ -2,7 +2,7 @@ # Way to use this: # cmsRun dumpHGCalEEDD4hep_cfg.py type=V17 # -# Options for type V16, V17 +# Options for type V16, V17, V18 # ############################################################################### import FWCore.ParameterSet.Config as cms @@ -16,7 +16,7 @@ "V17", VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, - "type of operations: V16, V17") + "type of operations: V16, V17, V18") ### get and parse the command line arguments options.parseArguments() diff --git a/Geometry/HGCalCommonData/test/python/dumpHGCalHEmixDD4hep_cfg.py b/Geometry/HGCalCommonData/test/python/dumpHGCalHEmixDD4hep_cfg.py index 59b4918d5745a..2da5649bf07fe 100644 --- a/Geometry/HGCalCommonData/test/python/dumpHGCalHEmixDD4hep_cfg.py +++ b/Geometry/HGCalCommonData/test/python/dumpHGCalHEmixDD4hep_cfg.py @@ -2,7 +2,7 @@ # Way to use this: # cmsRun dumpHGCalHEmixDD4hep_cfg.py type=V17 # -# Options for type V16, V17 +# Options for type V16, V17, V18 # ############################################################################### import FWCore.ParameterSet.Config as cms @@ -16,7 +16,7 @@ "V17", VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, - "type of operations: V16, V17") + "type of operations: V16, V17, V18") ### get and parse the command line arguments options.parseArguments() diff --git a/Geometry/HGCalCommonData/test/python/dumpHGCalHEsilDD4hep_cfg.py b/Geometry/HGCalCommonData/test/python/dumpHGCalHEsilDD4hep_cfg.py index 5fecbbdec9422..9d2d2592ff370 100644 --- a/Geometry/HGCalCommonData/test/python/dumpHGCalHEsilDD4hep_cfg.py +++ b/Geometry/HGCalCommonData/test/python/dumpHGCalHEsilDD4hep_cfg.py @@ -2,7 +2,7 @@ # Way to use this: # cmsRun dumpHGCalHEsilDD4hep_cfg.py type=V17 # -# Options for type V16, V17 +# Options for type V16, V17, V18 # ############################################################################### import FWCore.ParameterSet.Config as cms @@ -16,7 +16,7 @@ "V17", VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, - "type of operations: V16, V17") + "type of operations: V16, V17, V18") ### get and parse the command line arguments options.parseArguments() From 3968841c438bd4478719462bf381dfb5f6a85f0a Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 14 Jul 2023 04:21:01 +0200 Subject: [PATCH 2/2] Code Check --- .../dd4hep/DDHGCalMixRotatedCassette.cc | 292 +++++++++++------- 1 file changed, 176 insertions(+), 116 deletions(-) diff --git a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedCassette.cc b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedCassette.cc index e24ed65e3453e..a4a4b991dbf0c 100644 --- a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedCassette.cc +++ b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedCassette.cc @@ -49,7 +49,11 @@ struct HGCalMixRotatedCassette { phiBinsScint_ = args.value("NPhiBinScint"); forFireworks_ = args.value("ForFireWorks"); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette::Number of types of wafers: " << waferTypes_ << " passives: " << passiveTypes_ << " facings: " << facingTypes_ << " Orientations: " << orientationTypes_ << " PartialTypes: " << partialTypes_ << " PlaceOffset: " << placeOffset_ << "; number of cells along phi " << phiBinsScint_ << " forFireworks_: " << forFireworks_; + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette::Number of types of wafers: " << waferTypes_ + << " passives: " << passiveTypes_ << " facings: " << facingTypes_ + << " Orientations: " << orientationTypes_ << " PartialTypes: " << partialTypes_ + << " PlaceOffset: " << placeOffset_ << "; number of cells along phi " << phiBinsScint_ + << " forFireworks_: " << forFireworks_; #endif firstLayer_ = args.value("FirstLayer"); absorbMode_ = args.value("AbsorberMode"); @@ -66,10 +70,11 @@ struct HGCalMixRotatedCassette { alpha_ = (1._pi) / sectors_; cosAlpha_ = cos(alpha_); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: zStart " << cms::convert2mm(zMinBlock_) << " wafer width " - << cms::convert2mm(waferSize_) << " separations " << cms::convert2mm(waferSepar_) - << " sectors " << sectors_ << ":" << convertRadToDeg(alpha_) << ":" << cosAlpha_ - << " with " << cassettes_ << " cassettes"; + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: zStart " << cms::convert2mm(zMinBlock_) + << " wafer width " << cms::convert2mm(waferSize_) << " separations " + << cms::convert2mm(waferSepar_) << " sectors " << sectors_ << ":" + << convertRadToDeg(alpha_) << ":" << cosAlpha_ << " with " << cassettes_ + << " cassettes"; #endif slopeB_ = args.value>("SlopeBottom"); zFrontB_ = args.value>("ZFrontBottom"); @@ -113,13 +118,13 @@ struct HGCalMixRotatedCassette { passivePart_ = args.value>("PassiveNamesPartial"); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << passiveFull_.size() << " full and " - << passivePart_.size() << " partial passive modules"; + << passivePart_.size() << " partial passive modules"; i1max = static_cast(passiveFull_.size()); for (unsigned int i1 = 0; i1 < i1max; i1 += 2) { std::ostringstream st1; unsigned int i2 = std::min((i1 + 2), i1max); for (unsigned int i = i1; i < i2; ++i) - st1 << " [" << i << "] " << passiveFull_[i]; + st1 << " [" << i << "] " << passiveFull_[i]; edm::LogVerbatim("HGCalGeom") << st1.str(); } edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Partial Modules:"; @@ -128,7 +133,7 @@ struct HGCalMixRotatedCassette { std::ostringstream st1; unsigned int i2 = std::min((i1 + 2), i1max); for (unsigned int i = i1; i < i2; ++i) - st1 << " [" << i << "] " << passivePart_[i]; + st1 << " [" << i << "] " << passivePart_[i]; edm::LogVerbatim("HGCalGeom") << st1.str(); } #endif @@ -189,7 +194,9 @@ struct HGCalMixRotatedCassette { coverTypeTop_ = args.value("TopCoverLayerType"); copyNumberCoverTop_ = firstLayer_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << materialTop_.size() << " types of volumes in the top part; cover Type " << coverTypeTop_ << " with initial copy number " << copyNumberCoverTop_; + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << materialTop_.size() + << " types of volumes in the top part; cover Type " << coverTypeTop_ + << " with initial copy number " << copyNumberCoverTop_; for (unsigned int i = 0; i < materialTop_.size(); ++i) edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesTop_[i] << " of thickness " << cms::convert2mm(layerThickTop_[i]) << " filled with " << materialTop_[i] @@ -321,7 +328,7 @@ struct HGCalMixRotatedCassette { << cms::convert2mm(pgonRin[k]) << ":" << cms::convert2mm(pgonRout[k]); #endif } else { - int mode = (layerSense_[ly] > 0) ? sensitiveMode_ : absorbMode_; + int mode = (layerSense_[ly] > 0) ? sensitiveMode_ : absorbMode_; double rins = (mode < 1) ? rinB : HGCalGeomTools::radius(zz + hthick, zFrontB_, rMinFront_, slopeB_); double routs = (mode < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_); dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi); @@ -394,56 +401,75 @@ struct HGCalMixRotatedCassette { double thickTot(0), zpos(-hthick); if (absType < 0) { for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) { - int ii = layerTypeTop_[ly]; - int copy = copyNumberTop_[ii]; - int layer = copy - firstLayer_; - double hthickl = 0.5 * layerThickTop_[ii]; - thickTot += layerThickTop_[ii]; - zpos += hthickl; - dd4hep::Material matter1 = ns.material(materialTop_[ii]); - unsigned int k = 0; - int firstTile = tileLayerStart_[layer]; - int lastTile = ((layer + 1 < static_cast(tileLayerStart_.size())) ? tileLayerStart_[layer + 1] : static_cast(tileIndex_.size())); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << ly << ":" << ii << " Copy " << copy << " Tiles " << firstTile << ":" << lastTile; -#endif - for (int ti = firstTile; ti < lastTile; ++ti) { - double r1 = tileRMin_[std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; - double r2 = tileRMax_[std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; - int cassette = std::get<0>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); - int fimin = std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); - int fimax = std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); - double phi1 = dphi * (fimin - 1); - double phi2 = (forFireworks_ == 1) ? (dphi * (fimax - fimin + 1)) : (dphi * fimax); - auto cshift = cassette_.getShift(layer + 1, 1, cassette); -#ifdef EDM_ML_DEBUG - int cassette0 = HGCalCassette::cassetteType(2, 1, cassette); // - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << copy << ":" << (layer + 1) << " iR " << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << ":" << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << " R " << cms::convert2mm(r1) << ":" << cms::convert2mm(r2) << " Thick " << cms::convert2mm((2.0 * hthickl)) << " phi " << fimin << ":" << fimax << ":" << convertRadToDeg(phi1) << ":" << convertRadToDeg(phi2) << " cassette " << cassette << ":" << cassette0 << " Shift " << cms::convert2mm(cshift.first) << ":" << cms::convert2mm(cshift.second); -#endif - std::string name = namesTop_[ii] + "L" + std::to_string(copy) + "F" + std::to_string(k); - ++k; - dd4hep::Solid solid = dd4hep::Tube(r1, r2, hthickl, phi1, phi2); - ns.addSolidNS(ns.prepend(name), solid); - dd4hep::Volume glog1 = dd4hep::Volume(solid.name(), solid, matter1); - ns.addVolumeNS(glog1); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << glog1.name() << " Tubs made of " << materialTop_[ii] << " of dimensions " << cms::convert2mm(r1) << ", " << cms::convert2mm(r2) << ", " << cms::convert2mm(hthickl) << ", " << convertRadToDeg(phi1) << ", " << convertRadToDeg(phi2); -#endif - dd4hep::Position tran(-cshift.first, cshift.second, zpos); - glog.placeVolume(glog1, copy, tran); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Position " << glog1.name() << " number " << copy << " in " << glog.name() << " at (" << cms::convert2mm(cshift.first) << ", " << cms::convert2mm(cshift.second) << ", " << cms::convert2mm(zpos) << ") with no rotation"; -#endif - } - ++copyNumberTop_[ii]; - zpos += hthickl; + int ii = layerTypeTop_[ly]; + int copy = copyNumberTop_[ii]; + int layer = copy - firstLayer_; + double hthickl = 0.5 * layerThickTop_[ii]; + thickTot += layerThickTop_[ii]; + zpos += hthickl; + dd4hep::Material matter1 = ns.material(materialTop_[ii]); + unsigned int k = 0; + int firstTile = tileLayerStart_[layer]; + int lastTile = ((layer + 1 < static_cast(tileLayerStart_.size())) ? tileLayerStart_[layer + 1] + : static_cast(tileIndex_.size())); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << ly << ":" << ii << " Copy " << copy + << " Tiles " << firstTile << ":" << lastTile; +#endif + for (int ti = firstTile; ti < lastTile; ++ti) { + double r1 = tileRMin_[std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; + double r2 = tileRMax_[std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; + int cassette = std::get<0>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + int fimin = std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + int fimax = std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + double phi1 = dphi * (fimin - 1); + double phi2 = (forFireworks_ == 1) ? (dphi * (fimax - fimin + 1)) : (dphi * fimax); + auto cshift = cassette_.getShift(layer + 1, 1, cassette); +#ifdef EDM_ML_DEBUG + int cassette0 = HGCalCassette::cassetteType(2, 1, cassette); // + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << copy << ":" << (layer + 1) << " iR " + << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << ":" + << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << " R " + << cms::convert2mm(r1) << ":" << cms::convert2mm(r2) << " Thick " + << cms::convert2mm((2.0 * hthickl)) << " phi " << fimin << ":" << fimax << ":" + << convertRadToDeg(phi1) << ":" << convertRadToDeg(phi2) << " cassette " + << cassette << ":" << cassette0 << " Shift " << cms::convert2mm(cshift.first) + << ":" << cms::convert2mm(cshift.second); +#endif + std::string name = namesTop_[ii] + "L" + std::to_string(copy) + "F" + std::to_string(k); + ++k; + dd4hep::Solid solid = dd4hep::Tube(r1, r2, hthickl, phi1, phi2); + ns.addSolidNS(ns.prepend(name), solid); + dd4hep::Volume glog1 = dd4hep::Volume(solid.name(), solid, matter1); + ns.addVolumeNS(glog1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << glog1.name() << " Tubs made of " + << materialTop_[ii] << " of dimensions " << cms::convert2mm(r1) << ", " + << cms::convert2mm(r2) << ", " << cms::convert2mm(hthickl) << ", " + << convertRadToDeg(phi1) << ", " << convertRadToDeg(phi2); +#endif + dd4hep::Position tran(-cshift.first, cshift.second, zpos); + glog.placeVolume(glog1, copy, tran); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Position " << glog1.name() << " number " << copy + << " in " << glog.name() << " at (" << cms::convert2mm(cshift.first) << ", " + << cms::convert2mm(cshift.second) << ", " << cms::convert2mm(zpos) + << ") with no rotation"; +#endif + } + ++copyNumberTop_[ii]; + zpos += hthickl; } if (std::abs(thickTot - thick) > tol2_) { - if (thickTot > thick) { - edm::LogError("HGCalGeom") << "DDHGCalMixRotatedCassette: Thickness of the partition " << cms::convert2mm(thick) << " is smaller than " << cms::convert2mm(thickTot) << ": thickness of all its components in the top part **** ERROR ****"; - } else { - edm::LogWarning("HGCalGeom") << "DDHGCalMixRotatedCassette: Thickness of the partition " << cms::convert2mm(thick) << " does not match with " << cms::convert2mm(thickTot) << " of the components in top part"; - } + if (thickTot > thick) { + edm::LogError("HGCalGeom") << "DDHGCalMixRotatedCassette: Thickness of the partition " + << cms::convert2mm(thick) << " is smaller than " << cms::convert2mm(thickTot) + << ": thickness of all its components in the top part **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "DDHGCalMixRotatedCassette: Thickness of the partition " + << cms::convert2mm(thick) << " does not match with " << cms::convert2mm(thickTot) + << " of the components in top part"; + } } } else { int ii = coverTypeTop_; @@ -454,36 +480,51 @@ struct HGCalMixRotatedCassette { dd4hep::Material matter1 = ns.material(materialTop_[ii]); unsigned int k = 0; int firstTile = tileLayerStart_[layer]; - int lastTile = ((layer + 1 < static_cast(tileLayerStart_.size())) ? tileLayerStart_[layer + 1] : static_cast(tileIndex_.size())); + int lastTile = ((layer + 1 < static_cast(tileLayerStart_.size())) ? tileLayerStart_[layer + 1] + : static_cast(tileIndex_.size())); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << layer << ":" << ii << " Copy " << copy << " Tiles " << firstTile << ":" << lastTile; + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << layer << ":" << ii << " Copy " << copy + << " Tiles " << firstTile << ":" << lastTile; #endif for (int ti = firstTile; ti < lastTile; ++ti) { - double r1 = tileRMin_[std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; - double r2 = tileRMax_[std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; - int cassette = std::get<0>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); - int fimin = std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); - int fimax = std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); - double phi1 = dphi * (fimin - 1); - double phi2 = (forFireworks_ == 1) ? (dphi * (fimax - fimin + 1)) : (dphi * fimax); - auto cshift = cassette_.getShift(layer + 1, 1, cassette); -#ifdef EDM_ML_DEBUG - int cassette0 = HGCalCassette::cassetteType(2, 1, cassette); // - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << copy << ":" << (layer + 1) << " iR " << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << ":" << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << " R " << cms::convert2mm(r1) << ":" << cms::convert2mm(r2) << " Thick " << cms::convert2mm(2.0 * hthickl) << " phi " << fimin << ":" << fimax << ":" << convertRadToDeg(phi1) << ":" << convertRadToDeg(phi2) << " cassette " << cassette << ":" << cassette0 << " Shift " << cms::convert2mm(cshift.first) << ":" << cms::convert2mm(cshift.second); -#endif - std::string name = namesTop_[ii] + "L" + std::to_string(copy) + "F" + std::to_string(k); - ++k; - dd4hep::Solid solid = dd4hep::Tube(r1, r2, hthickl, phi1, phi2); - ns.addSolidNS(ns.prepend(name), solid); - dd4hep::Volume glog1 = dd4hep::Volume(solid.name(), solid, matter1); - ns.addVolumeNS(glog1); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << glog1.name() << " Tubs made of " << matter1.name() << " of dimensions " << cms::convert2mm(r1) << ", " << cms::convert2mm(r2) << ", " << cms::convert2mm(hthickl) << ", " << convertRadToDeg(phi1) << ", " << convertRadToDeg(phi2); -#endif - dd4hep::Position tran(-cshift.first, cshift.second, zpos); - glog.placeVolume(glog1, copy, tran); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Position " << glog1.name() << " number " << copy << " in " << glog.name() << " at (" << cms::convert2mm(cshift.first) << ", " << cms::convert2mm(cshift.second) << ", " << cms::convert2mm(zpos) << ") with no rotation"; + double r1 = tileRMin_[std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; + double r2 = tileRMax_[std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) - 1]; + int cassette = std::get<0>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + int fimin = std::get<1>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + int fimax = std::get<2>(HGCalTileIndex::tileUnpack(tilePhis_[ti])); + double phi1 = dphi * (fimin - 1); + double phi2 = (forFireworks_ == 1) ? (dphi * (fimax - fimin + 1)) : (dphi * fimax); + auto cshift = cassette_.getShift(layer + 1, 1, cassette); +#ifdef EDM_ML_DEBUG + int cassette0 = HGCalCassette::cassetteType(2, 1, cassette); // + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Layer " << copy << ":" << (layer + 1) << " iR " + << std::get<1>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << ":" + << std::get<2>(HGCalTileIndex::tileUnpack(tileIndex_[ti])) << " R " + << cms::convert2mm(r1) << ":" << cms::convert2mm(r2) << " Thick " + << cms::convert2mm(2.0 * hthickl) << " phi " << fimin << ":" << fimax << ":" + << convertRadToDeg(phi1) << ":" << convertRadToDeg(phi2) << " cassette " + << cassette << ":" << cassette0 << " Shift " << cms::convert2mm(cshift.first) + << ":" << cms::convert2mm(cshift.second); +#endif + std::string name = namesTop_[ii] + "L" + std::to_string(copy) + "F" + std::to_string(k); + ++k; + dd4hep::Solid solid = dd4hep::Tube(r1, r2, hthickl, phi1, phi2); + ns.addSolidNS(ns.prepend(name), solid); + dd4hep::Volume glog1 = dd4hep::Volume(solid.name(), solid, matter1); + ns.addVolumeNS(glog1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: " << glog1.name() << " Tubs made of " + << matter1.name() << " of dimensions " << cms::convert2mm(r1) << ", " + << cms::convert2mm(r2) << ", " << cms::convert2mm(hthickl) << ", " + << convertRadToDeg(phi1) << ", " << convertRadToDeg(phi2); +#endif + dd4hep::Position tran(-cshift.first, cshift.second, zpos); + glog.placeVolume(glog1, copy, tran); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette: Position " << glog1.name() << " number " << copy + << " in " << glog.name() << " at (" << cms::convert2mm(cshift.first) << ", " + << cms::convert2mm(cshift.second) << ", " << cms::convert2mm(zpos) + << ") with no rotation"; #endif } ++copyNumberCoverTop_; @@ -527,9 +568,9 @@ struct HGCalMixRotatedCassette { int place = HGCalCell::cellPlacementIndex(1, layertype, orien); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") - << "DDHGCalMixRotatedCassette::index:Property:layertype:type:part:orien:cassette:place:offsets:ind " << k << ":" - << waferProperty_[k] << ":" << layertype << ":" << type << ":" << part << ":" << orien << ":" << cassette - << ":" << place; + << "DDHGCalMixRotatedCassette::index:Property:layertype:type:part:orien:cassette:place:offsets:ind " << k + << ":" << waferProperty_[k] << ":" << layertype << ":" << type << ":" << part << ":" << orien << ":" + << cassette << ":" << place; #endif auto cshift = cassette_.getShift(layer + 1, -1, cassette); double xpos = xyoff.first - cshift.first + nc * delx; @@ -538,50 +579,69 @@ struct HGCalMixRotatedCassette { double xorig = xyoff.first + nc * delx; double yorig = xyoff.second + nr * dy; double angle = std::atan2(yorig, xorig); - edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette::Wafer: layer " << layer + 1 << " cassette " << cassette << " Shift " << cms::convert2mm(cshift.first) << ":" << cms::convert2mm(cshift.second) << " Original " << cms::convert2mm(xorig) << ":" << cms::convert2mm(yorig) << ":" << convertRadToDeg(angle) << " Final " << cms::convert2mm(xpos) << ":" << cms::convert2mm(ypos); + edm::LogVerbatim("HGCalGeom") << "DDHGCalMixRotatedCassette::Wafer: layer " << layer + 1 << " cassette " + << cassette << " Shift " << cms::convert2mm(cshift.first) << ":" + << cms::convert2mm(cshift.second) << " Original " << cms::convert2mm(xorig) << ":" + << cms::convert2mm(yorig) << ":" << convertRadToDeg(angle) << " Final " + << cms::convert2mm(xpos) << ":" << cms::convert2mm(ypos); #endif std::string wafer; int i(999); if (absType < 0) { - if (part == HGCalTypes::WaferFull) { - i = type * facingTypes_ * orientationTypes_ + place - placeOffset_; + if (part == HGCalTypes::WaferFull) { + i = type * facingTypes_ * orientationTypes_ + place - placeOffset_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << " FullWafer type:place:ind " << type << ":" << place << ":" << i << ":" << waferFull_.size(); + edm::LogVerbatim("HGCalGeom") << " FullWafer type:place:ind " << type << ":" << place << ":" << i << ":" + << waferFull_.size(); #endif - wafer = waferFull_[i]; - } else { - int partoffset = (part >= HGCalTypes::WaferHDTop) ? HGCalTypes::WaferPartHDOffset : HGCalTypes::WaferPartLDOffset; - i = (part - partoffset) * facingTypes_ * orientationTypes_ + HGCalTypes::WaferTypeOffset[type] * facingTypes_ * orientationTypes_ + place - placeOffset_; + wafer = waferFull_[i]; + } else { + int partoffset = + (part >= HGCalTypes::WaferHDTop) ? HGCalTypes::WaferPartHDOffset : HGCalTypes::WaferPartLDOffset; + i = (part - partoffset) * facingTypes_ * orientationTypes_ + + HGCalTypes::WaferTypeOffset[type] * facingTypes_ * orientationTypes_ + place - placeOffset_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << " layertype:type:part:orien:cassette:place:offsets:ind " << layertype << ":" << type << ":" << part << ":" << orien << ":" << cassette << ":" << place << ":" << partoffset << ":" << HGCalTypes::WaferTypeOffset[type] << ":" << i << ":" << waferPart_.size(); + edm::LogVerbatim("HGCalGeom") << " layertype:type:part:orien:cassette:place:offsets:ind " << layertype << ":" + << type << ":" << part << ":" << orien << ":" << cassette << ":" << place << ":" + << partoffset << ":" << HGCalTypes::WaferTypeOffset[type] << ":" << i << ":" + << waferPart_.size(); #endif - wafer = waferPart_[i]; - } + wafer = waferPart_[i]; + } } else { - type = absType; - if (part == HGCalTypes::WaferFull) { - i = absType - 1; - wafer = passiveFull_[i]; -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:offsets:ind " << layertype << ":" << absType << ":" << part << ":" << orien << ":" << cassette << ":" << ":" << partialTypes_ << ":" << orientationTypes_ << " passive " << i << ":" << wafer; -#endif - } else { - int partoffset = (part >= HGCalTypes::WaferHDTop) ? HGCalTypes::WaferPartHDOffset : (HGCalTypes::WaferPartLDOffset - HGCalTypes::WaferTypeOffset[1]); - i = (part - partoffset) * facingTypes_ * orientationTypes_ + (absType - 1) * facingTypes_ * orientationTypes_ * partialTypes_ + place - placeOffset_; + type = absType; + if (part == HGCalTypes::WaferFull) { + i = absType - 1; + wafer = passiveFull_[i]; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:3Types:offset:ind " << layertype << ":"<< absType << ":" << part << ":" << orien << ":" << cassette << ":" << partialTypes_ << ":" << facingTypes_ << ":" << orientationTypes_ << ":" << partoffset << ":" << i << ":" << passivePart_.size(); + edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:offsets:ind " << layertype << ":" + << absType << ":" << part << ":" << orien << ":" << cassette << ":" + << ":" << partialTypes_ << ":" << orientationTypes_ << " passive " << i << ":" + << wafer; #endif - wafer = passivePart_[i]; - } + } else { + int partoffset = (part >= HGCalTypes::WaferHDTop) + ? HGCalTypes::WaferPartHDOffset + : (HGCalTypes::WaferPartLDOffset - HGCalTypes::WaferTypeOffset[1]); + i = (part - partoffset) * facingTypes_ * orientationTypes_ + + (absType - 1) * facingTypes_ * orientationTypes_ * partialTypes_ + place - placeOffset_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:3Types:offset:ind " << layertype + << ":" << absType << ":" << part << ":" << orien << ":" << cassette << ":" + << partialTypes_ << ":" << facingTypes_ << ":" << orientationTypes_ << ":" + << partoffset << ":" << i << ":" << passivePart_.size(); +#endif + wafer = passivePart_[i]; + } } int copy = HGCalTypes::packTypeUV(type, u, v); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << " DDHGCalMixRotatedCassette: Layer " << HGCalWaferIndex::waferLayer(waferIndex_[k]) - << " Wafer " << wafer << " number " << copy << " type :part:orien:ind " << type - << ":" << part << ":" << orien << ":" << i << " layer:u:v " << (layer + firstLayer_) - << ":" << u << ":" << v; + edm::LogVerbatim("HGCalGeom") << " DDHGCalMixRotatedCassette: Layer " + << HGCalWaferIndex::waferLayer(waferIndex_[k]) << " Wafer " << wafer << " number " + << copy << " type :part:orien:ind " << type << ":" << part << ":" << orien << ":" + << i << " layer:u:v " << (layer + firstLayer_) << ":" << u << ":" << v; if (iu > ium) ium = iu; if (iv > ivm)