File indexing completed on 2024-04-06 12:14:58
0001
0002
0003
0004
0005
0006 #include "DataFormats/Math/interface/angle_units.h"
0007 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0008 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0009 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0010 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0011 #include "DetectorDescription/Core/interface/DDMaterial.h"
0012 #include "DetectorDescription/Core/interface/DDSolid.h"
0013 #include "DetectorDescription/Core/interface/DDSplit.h"
0014 #include "DetectorDescription/Core/interface/DDTypes.h"
0015 #include "DetectorDescription/Core/interface/DDutils.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/PluginManager/interface/PluginFactory.h"
0018 #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h"
0019 #include "Geometry/HGCalCommonData/interface/HGCalParameters.h"
0020 #include "Geometry/HGCalCommonData/interface/HGCalProperty.h"
0021 #include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
0022 #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h"
0023 #include "Geometry/HGCalCommonData/interface/HGCalWaferType.h"
0024
0025 #include <cmath>
0026 #include <memory>
0027 #include <string>
0028 #include <unordered_set>
0029 #include <vector>
0030
0031
0032 using namespace angle_units::operators;
0033
0034 class DDHGCalHEFileAlgo : public DDAlgorithm {
0035 public:
0036 DDHGCalHEFileAlgo();
0037
0038 void initialize(const DDNumericArguments& nArgs,
0039 const DDVectorArguments& vArgs,
0040 const DDMapArguments& mArgs,
0041 const DDStringArguments& sArgs,
0042 const DDStringVectorArguments& vsArgs) override;
0043 void execute(DDCompactView& cpv) override;
0044
0045 protected:
0046 void constructLayers(const DDLogicalPart&, DDCompactView& cpv);
0047 void positionMix(const DDLogicalPart& glog,
0048 const std::string& name,
0049 int copy,
0050 double thick,
0051 const DDMaterial& matter,
0052 double rin,
0053 double rmid,
0054 double routF,
0055 double zz,
0056 DDCompactView& cpv);
0057 void positionSensitive(
0058 const DDLogicalPart& glog, double rin, double rout, double zpos, int layertype, int layer, DDCompactView& cpv);
0059
0060 private:
0061 HGCalGeomTools geomTools_;
0062
0063 static constexpr double tol1_ = 0.01;
0064 static constexpr double tol2_ = 0.00001;
0065
0066 std::vector<std::string> wafers_;
0067 std::vector<std::string> materials_;
0068 std::vector<std::string> names_;
0069 std::vector<double> thick_;
0070 std::vector<int> copyNumber_;
0071 std::vector<int> layers_;
0072 std::vector<double> layerThick_;
0073 std::vector<double> rMixLayer_;
0074 std::vector<int> layerType_;
0075 std::vector<int> layerSense_;
0076 int firstLayer_;
0077 int absorbMode_;
0078 int sensitiveMode_;
0079 std::vector<std::string> materialsTop_;
0080 std::vector<std::string> namesTop_;
0081 std::vector<double> layerThickTop_;
0082 std::vector<int> layerTypeTop_;
0083 std::vector<int> copyNumberTop_;
0084 std::vector<std::string> materialsBot_;
0085 std::vector<std::string> namesBot_;
0086 std::vector<double> layerThickBot_;
0087 std::vector<int> layerTypeBot_;
0088 std::vector<int> copyNumberBot_;
0089 std::vector<int> layerSenseBot_;
0090 std::vector<int> layerCenter_;
0091
0092 double zMinBlock_;
0093 std::vector<int> waferIndex_;
0094 std::vector<int> waferProperty_;
0095 double waferSize_;
0096 double waferSepar_;
0097 int sectors_;
0098 std::vector<double> slopeB_;
0099 std::vector<double> zFrontB_;
0100 std::vector<double> rMinFront_;
0101 std::vector<double> slopeT_;
0102 std::vector<double> zFrontT_;
0103 std::vector<double> rMaxFront_;
0104 std::string nameSpace_;
0105 std::unordered_set<int> copies_;
0106 double alpha_, cosAlpha_;
0107 };
0108
0109 DDHGCalHEFileAlgo::DDHGCalHEFileAlgo() {
0110 #ifdef EDM_ML_DEBUG
0111 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: Creating an instance";
0112 #endif
0113 }
0114
0115 void DDHGCalHEFileAlgo::initialize(const DDNumericArguments& nArgs,
0116 const DDVectorArguments& vArgs,
0117 const DDMapArguments&,
0118 const DDStringArguments& sArgs,
0119 const DDStringVectorArguments& vsArgs) {
0120 wafers_ = vsArgs["WaferNames"];
0121 #ifdef EDM_ML_DEBUG
0122 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << wafers_.size() << " wafers";
0123 for (unsigned int i = 0; i < wafers_.size(); ++i)
0124 edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafers_[i];
0125 #endif
0126 materials_ = vsArgs["MaterialNames"];
0127 names_ = vsArgs["VolumeNames"];
0128 thick_ = vArgs["Thickness"];
0129 copyNumber_.resize(materials_.size(), 1);
0130 #ifdef EDM_ML_DEBUG
0131 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << materials_.size() << " types of volumes";
0132 for (unsigned int i = 0; i < names_.size(); ++i)
0133 edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] << " of thickness " << thick_[i]
0134 << " filled with " << materials_[i] << " first copy number " << copyNumber_[i];
0135 #endif
0136 layers_ = dbl_to_int(vArgs["Layers"]);
0137 layerThick_ = vArgs["LayerThick"];
0138 rMixLayer_ = vArgs["LayerRmix"];
0139 #ifdef EDM_ML_DEBUG
0140 edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks";
0141 for (unsigned int i = 0; i < layers_.size(); ++i)
0142 edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick_[i] << " Rmid " << rMixLayer_[i]
0143 << " with " << layers_[i] << " layers";
0144 #endif
0145 layerType_ = dbl_to_int(vArgs["LayerType"]);
0146 layerSense_ = dbl_to_int(vArgs["LayerSense"]);
0147 firstLayer_ = (int)(nArgs["FirstLayer"]);
0148 absorbMode_ = (int)(nArgs["AbsorberMode"]);
0149 sensitiveMode_ = (int)(nArgs["SensitiveMode"]);
0150 #ifdef EDM_ML_DEBUG
0151 edm::LogVerbatim("HGCalGeom") << "First Layer " << firstLayer_ << " and "
0152 << "Absober:Sensitive mode " << absorbMode_ << ":" << sensitiveMode_;
0153 #endif
0154 layerCenter_ = dbl_to_int(vArgs["LayerCenter"]);
0155 #ifdef EDM_ML_DEBUG
0156 for (unsigned int i = 0; i < layerCenter_.size(); ++i)
0157 edm::LogVerbatim("HGCalGeom") << "LayerCenter [" << i << "] " << layerCenter_[i];
0158 #endif
0159 if (firstLayer_ > 0) {
0160 for (unsigned int i = 0; i < layerType_.size(); ++i) {
0161 if (layerSense_[i] > 0) {
0162 int ii = layerType_[i];
0163 copyNumber_[ii] = firstLayer_;
0164 #ifdef EDM_ML_DEBUG
0165 edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " << i << ":" << ii << " with "
0166 << materials_[ii] << " changed to " << copyNumber_[ii];
0167 #endif
0168 break;
0169 }
0170 }
0171 } else {
0172 firstLayer_ = 1;
0173 }
0174 #ifdef EDM_ML_DEBUG
0175 edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
0176 for (unsigned int i = 0; i < layerType_.size(); ++i)
0177 edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class "
0178 << layerSense_[i];
0179 #endif
0180 materialsTop_ = vsArgs["TopMaterialNames"];
0181 namesTop_ = vsArgs["TopVolumeNames"];
0182 layerThickTop_ = vArgs["TopLayerThickness"];
0183 layerTypeTop_ = dbl_to_int(vArgs["TopLayerType"]);
0184 copyNumberTop_.resize(materialsTop_.size(), 1);
0185 #ifdef EDM_ML_DEBUG
0186 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << materialsTop_.size() << " types of volumes in the top part";
0187 for (unsigned int i = 0; i < materialsTop_.size(); ++i)
0188 edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesTop_[i] << " of thickness " << layerThickTop_[i]
0189 << " filled with " << materialsTop_[i] << " first copy number " << copyNumberTop_[i];
0190 edm::LogVerbatim("HGCalGeom") << "There are " << layerTypeTop_.size() << " layers in the top part";
0191 for (unsigned int i = 0; i < layerTypeTop_.size(); ++i)
0192 edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerTypeTop_[i];
0193 #endif
0194 materialsBot_ = vsArgs["BottomMaterialNames"];
0195 namesBot_ = vsArgs["BottomVolumeNames"];
0196 layerTypeBot_ = dbl_to_int(vArgs["BottomLayerType"]);
0197 layerSenseBot_ = dbl_to_int(vArgs["BottomLayerSense"]);
0198 layerThickBot_ = vArgs["BottomLayerThickness"];
0199 copyNumberBot_.resize(materialsBot_.size(), 1);
0200 #ifdef EDM_ML_DEBUG
0201 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << materialsBot_.size()
0202 << " types of volumes in the bottom part";
0203 for (unsigned int i = 0; i < materialsBot_.size(); ++i)
0204 edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesBot_[i] << " of thickness " << layerThickBot_[i]
0205 << " filled with " << materialsBot_[i] << " first copy number " << copyNumberBot_[i];
0206 edm::LogVerbatim("HGCalGeom") << "There are " << layerTypeBot_.size() << " layers in the bottom part";
0207 for (unsigned int i = 0; i < layerTypeBot_.size(); ++i)
0208 edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerTypeBot_[i]
0209 << " sensitive class " << layerSenseBot_[i];
0210 #endif
0211 zMinBlock_ = nArgs["zMinBlock"];
0212 waferSize_ = nArgs["waferSize"];
0213 waferSepar_ = nArgs["SensorSeparation"];
0214 sectors_ = (int)(nArgs["Sectors"]);
0215 alpha_ = (1._pi) / sectors_;
0216 cosAlpha_ = cos(alpha_);
0217 #ifdef EDM_ML_DEBUG
0218 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: zStart " << zMinBlock_ << " wafer width " << waferSize_
0219 << " separations " << waferSepar_ << " sectors " << sectors_ << ":"
0220 << convertRadToDeg(alpha_) << ":" << cosAlpha_;
0221 #endif
0222 waferIndex_ = dbl_to_int(vArgs["WaferIndex"]);
0223 waferProperty_ = dbl_to_int(vArgs["WaferProperties"]);
0224 #ifdef EDM_ML_DEBUG
0225 edm::LogVerbatim("HGCalGeom") << "waferProperties with " << waferIndex_.size() << " entries";
0226 for (unsigned int k = 0; k < waferIndex_.size(); ++k)
0227 edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << waferIndex_[k] << " ("
0228 << HGCalWaferIndex::waferLayer(waferIndex_[k]) << ", "
0229 << HGCalWaferIndex::waferU(waferIndex_[k]) << ", "
0230 << HGCalWaferIndex::waferV(waferIndex_[k]) << ") : ("
0231 << HGCalProperty::waferThick(waferProperty_[k]) << ":"
0232 << HGCalProperty::waferPartial(waferProperty_[k]) << ":"
0233 << HGCalProperty::waferOrient(waferProperty_[k]) << ")";
0234 #endif
0235 slopeB_ = vArgs["SlopeBottom"];
0236 zFrontB_ = vArgs["ZFrontBottom"];
0237 rMinFront_ = vArgs["RMinFront"];
0238 slopeT_ = vArgs["SlopeTop"];
0239 zFrontT_ = vArgs["ZFrontTop"];
0240 rMaxFront_ = vArgs["RMaxFront"];
0241 #ifdef EDM_ML_DEBUG
0242 for (unsigned int i = 0; i < slopeB_.size(); ++i)
0243 edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFrontB_[i] << " Rmin " << rMinFront_[i]
0244 << " Slope " << slopeB_[i];
0245 for (unsigned int i = 0; i < slopeT_.size(); ++i)
0246 edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFrontT_[i] << " Rmax " << rMaxFront_[i]
0247 << " Slope " << slopeT_[i];
0248 #endif
0249 nameSpace_ = DDCurrentNamespace::ns();
0250 #ifdef EDM_ML_DEBUG
0251 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: NameSpace " << nameSpace_ << ":";
0252 #endif
0253 }
0254
0255
0256
0257
0258
0259 void DDHGCalHEFileAlgo::execute(DDCompactView& cpv) {
0260 #ifdef EDM_ML_DEBUG
0261 edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalHEFileAlgo...";
0262 copies_.clear();
0263 #endif
0264 constructLayers(parent(), cpv);
0265 #ifdef EDM_ML_DEBUG
0266 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << copies_.size() << " different wafer copy numbers";
0267 int k(0);
0268 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++k) {
0269 edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr);
0270 }
0271 copies_.clear();
0272 edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalHEFileAlgo construction...";
0273 #endif
0274 }
0275
0276 void DDHGCalHEFileAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& cpv) {
0277 double zi(zMinBlock_);
0278 int laymin(0);
0279 for (unsigned int i = 0; i < layers_.size(); i++) {
0280 double zo = zi + layerThick_[i];
0281 double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_);
0282 int laymax = laymin + layers_[i];
0283 double zz = zi;
0284 double thickTot(0);
0285 for (int ly = laymin; ly < laymax; ++ly) {
0286 int ii = layerType_[ly];
0287 int copy = copyNumber_[ii];
0288 double hthick = 0.5 * thick_[ii];
0289 double rinB = HGCalGeomTools::radius(zo, zFrontB_, rMinFront_, slopeB_);
0290 zz += hthick;
0291 thickTot += thick_[ii];
0292
0293 std::string name = names_[ii] + std::to_string(copy);
0294 #ifdef EDM_ML_DEBUG
0295 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: Layer " << ly << ":" << ii << " Front " << zi << ", "
0296 << routF << " Back " << zo << ", " << rinB << " superlayer thickness "
0297 << layerThick_[i];
0298 #endif
0299 DDName matName(DDSplit(materials_[ii]).first, DDSplit(materials_[ii]).second);
0300 DDMaterial matter(matName);
0301 DDLogicalPart glog;
0302 if (layerSense_[ly] < 1) {
0303 std::vector<double> pgonZ, pgonRin, pgonRout;
0304 double rmax =
0305 (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, rMaxFront_, slopeT_)) * cosAlpha_) - tol1_;
0306 HGCalGeomTools::radius(zz - hthick,
0307 zz + hthick,
0308 zFrontB_,
0309 rMinFront_,
0310 slopeB_,
0311 zFrontT_,
0312 rMaxFront_,
0313 slopeT_,
0314 -layerSense_[ly],
0315 pgonZ,
0316 pgonRin,
0317 pgonRout);
0318 for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
0319 pgonZ[isec] -= zz;
0320 if (layerSense_[ly] == 0 || absorbMode_ == 0)
0321 pgonRout[isec] = rmax;
0322 else
0323 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
0324 }
0325 DDSolid solid =
0326 DDSolidFactory::polyhedra(DDName(name, nameSpace_), sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
0327 glog = DDLogicalPart(solid.ddname(), matter, solid);
0328 #ifdef EDM_ML_DEBUG
0329 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << solid.name() << " polyhedra of " << sectors_
0330 << " sectors covering " << convertRadToDeg(-alpha_) << ":"
0331 << convertRadToDeg(-alpha_ + 2._pi) << " with " << pgonZ.size() << " sections";
0332 for (unsigned int k = 0; k < pgonZ.size(); ++k)
0333 edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] << ":" << pgonRout[k];
0334 #endif
0335 } else {
0336 double rins = (sensitiveMode_ < 1) ? rinB : HGCalGeomTools::radius(zz + hthick, zFrontB_, rMinFront_, slopeB_);
0337 double routs =
0338 (sensitiveMode_ < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_);
0339 DDSolid solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rins, routs, 0.0, 2._pi);
0340 glog = DDLogicalPart(solid.ddname(), matter, solid);
0341 #ifdef EDM_ML_DEBUG
0342 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << solid.name() << " Tubs made of " << matName
0343 << " of dimensions " << rinB << ":" << rins << ", " << routF << ":" << routs
0344 << ", " << hthick << ", 0.0, 360.0 and positioned in: " << glog.name()
0345 << " number " << copy;
0346 #endif
0347 positionMix(glog, name, copy, thick_[ii], matter, rins, rMixLayer_[i], routs, zz, cpv);
0348 }
0349 DDTranslation r1(0, 0, zz);
0350 DDRotation rot;
0351 cpv.position(glog, module, copy, r1, rot);
0352 ++copyNumber_[ii];
0353 #ifdef EDM_ML_DEBUG
0354 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << glog.name() << " number " << copy << " positioned in "
0355 << module.name() << " at " << r1 << " with no rotation";
0356 #endif
0357 zz += hthick;
0358 }
0359 zi = zo;
0360 laymin = laymax;
0361
0362 if (std::abs(thickTot - layerThick_[i]) >= tol2_) {
0363 if (thickTot > layerThick_[i]) {
0364 edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot
0365 << ": thickness of all its components **** ERROR ****";
0366 } else {
0367 edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with "
0368 << thickTot << " of the components";
0369 }
0370 }
0371 }
0372 }
0373
0374 void DDHGCalHEFileAlgo::positionMix(const DDLogicalPart& glog,
0375 const std::string& nameM,
0376 int copyM,
0377 double thick,
0378 const DDMaterial& matter,
0379 double rin,
0380 double rmid,
0381 double rout,
0382 double zz,
0383 DDCompactView& cpv) {
0384 DDLogicalPart glog1;
0385 DDTranslation tran;
0386 DDRotation rot;
0387 for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
0388 int ii = layerTypeTop_[ly];
0389 copyNumberTop_[ii] = copyM;
0390 }
0391 for (unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
0392 int ii = layerTypeBot_[ly];
0393 copyNumberBot_[ii] = copyM;
0394 }
0395 double hthick = 0.5 * thick;
0396
0397 std::string name = nameM + "Top";
0398 DDSolid solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rmid, rout, 0.0, 2._pi);
0399 glog1 = DDLogicalPart(solid.ddname(), matter, solid);
0400 #ifdef EDM_ML_DEBUG
0401 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << solid.name() << " Tubs made of " << matter.name()
0402 << " of dimensions " << rmid << ", " << rout << ", " << hthick << ", 0.0, 360.0";
0403 #endif
0404 cpv.position(glog1, glog, 1, tran, rot);
0405 #ifdef EDM_ML_DEBUG
0406 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << glog1.name() << " number 1 positioned in " << glog.name()
0407 << " at " << tran << " with no rotation";
0408 #endif
0409 double thickTot(0), zpos(-hthick);
0410 for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
0411 int ii = layerTypeTop_[ly];
0412 int copy = copyNumberTop_[ii];
0413 double hthickl = 0.5 * layerThickTop_[ii];
0414 thickTot += layerThickTop_[ii];
0415 name = namesTop_[ii] + std::to_string(copy);
0416 #ifdef EDM_ML_DEBUG
0417 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: Layer " << ly << ":" << ii << " R " << rmid << ":" << rout
0418 << " Thick " << layerThickTop_[ii];
0419 #endif
0420 DDName matName(DDSplit(materialsTop_[ii]).first, DDSplit(materialsTop_[ii]).second);
0421 DDMaterial matter1(matName);
0422 solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthickl, rmid, rout, 0.0, 2._pi);
0423 DDLogicalPart glog2 = DDLogicalPart(solid.ddname(), matter1, solid);
0424 #ifdef EDM_ML_DEBUG
0425 double eta1 = -log(tan(0.5 * atan(rmid / zz)));
0426 double eta2 = -log(tan(0.5 * atan(rout / zz)));
0427 edm::LogVerbatim("HGCalGeom") << name << " z|rin|rout " << zz << ":" << rmid << ":" << rout << " eta " << eta1
0428 << ":" << eta2;
0429 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << solid.name() << " Tubs made of " << matName
0430 << " of dimensions " << rmid << ", " << rout << ", " << hthickl << ", 0.0, 360.0";
0431 #endif
0432 zpos += hthickl;
0433 DDTranslation r1(0, 0, zpos);
0434 cpv.position(glog2, glog1, copy, r1, rot);
0435 #ifdef EDM_ML_DEBUG
0436 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: Position " << glog2.name() << " number " << copy << " in "
0437 << glog1.name() << " at " << r1 << " with no rotation";
0438 #endif
0439 ++copyNumberTop_[ii];
0440 zpos += hthickl;
0441 }
0442 if (std::abs(thickTot - thick) >= tol2_) {
0443 if (thickTot > thick) {
0444 edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot
0445 << ": thickness of all its components in the top part **** ERROR ****";
0446 } else {
0447 edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot
0448 << " of the components in top part";
0449 }
0450 }
0451
0452
0453 name = nameM + "Bottom";
0454 solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rin, rmid, 0.0, 2._pi);
0455 glog1 = DDLogicalPart(solid.ddname(), matter, solid);
0456 #ifdef EDM_ML_DEBUG
0457 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << solid.name() << " Tubs made of " << matter.name()
0458 << " of dimensions " << rin << ", " << rmid << ", " << hthick << ", 0.0, 360.0";
0459 #endif
0460 cpv.position(glog1, glog, 1, tran, rot);
0461 #ifdef EDM_ML_DEBUG
0462 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << glog1.name() << " number 1 positioned in " << glog.name()
0463 << " at " << tran << " with no rotation";
0464 #endif
0465 thickTot = 0;
0466 zpos = -hthick;
0467 for (unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
0468 int ii = layerTypeBot_[ly];
0469 int copy = copyNumberBot_[ii];
0470 double hthickl = 0.5 * layerThickBot_[ii];
0471 thickTot += layerThickBot_[ii];
0472 name = namesBot_[ii] + std::to_string(copy);
0473 #ifdef EDM_ML_DEBUG
0474 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: Layer " << ly << ":" << ii << " R " << rin << ":" << rmid
0475 << " Thick " << layerThickBot_[ii];
0476 #endif
0477 DDName matName(DDSplit(materialsBot_[ii]).first, DDSplit(materialsBot_[ii]).second);
0478 DDMaterial matter1(matName);
0479 solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthickl, rin, rmid, 0.0, 2._pi);
0480 DDLogicalPart glog2 = DDLogicalPart(solid.ddname(), matter1, solid);
0481 #ifdef EDM_ML_DEBUG
0482 double eta1 = -log(tan(0.5 * atan(rin / zz)));
0483 double eta2 = -log(tan(0.5 * atan(rmid / zz)));
0484 edm::LogVerbatim("HGCalGeom") << name << " z|rin|rout " << zz << ":" << rin << ":" << rmid << " eta " << eta1 << ":"
0485 << eta2;
0486 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << solid.name() << " Tubs made of " << matName
0487 << " of dimensions " << rin << ", " << rmid << ", " << hthickl << ", 0.0, 360.0";
0488 #endif
0489 zpos += hthickl;
0490 DDTranslation r1(0, 0, zpos);
0491 cpv.position(glog2, glog1, copy, r1, rot);
0492 #ifdef EDM_ML_DEBUG
0493 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: Position " << glog2.name() << " number " << copy << " in "
0494 << glog1.name() << " at " << r1 << " with no rotation";
0495 #endif
0496 if (layerSenseBot_[ly] != 0) {
0497 #ifdef EDM_ML_DEBUG
0498 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: z " << (zz + zpos) << " Center " << copy << ":"
0499 << (copy - firstLayer_) << ":" << layerCenter_[copy - firstLayer_];
0500 #endif
0501 positionSensitive(glog2, rin, rmid, zz + zpos, layerSenseBot_[ly], (copy - firstLayer_), cpv);
0502 }
0503 zpos += hthickl;
0504 ++copyNumberBot_[ii];
0505 }
0506 if (std::abs(thickTot - thick) >= tol2_) {
0507 if (thickTot > thick) {
0508 edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot
0509 << ": thickness of all its components in the top part **** ERROR ****";
0510 } else {
0511 edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot
0512 << " of the components in top part";
0513 }
0514 }
0515 }
0516
0517 void DDHGCalHEFileAlgo::positionSensitive(
0518 const DDLogicalPart& glog, double rin, double rout, double zpos, int layertype, int layer, DDCompactView& cpv) {
0519 static const double sqrt3 = std::sqrt(3.0);
0520 int layercenter = layerCenter_[layer];
0521 double r = 0.5 * (waferSize_ + waferSepar_);
0522 double R = 2.0 * r / sqrt3;
0523 double dy = 0.75 * R;
0524 int N = (int)(0.5 * rout / r) + 2;
0525 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
0526 #ifdef EDM_ML_DEBUG
0527 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0);
0528 std::vector<int> ntype(6, 0);
0529 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: " << glog.ddname() << " rin:rout " << rin << ":" << rout
0530 << " zpos " << zpos << " N " << N << " for maximum u, v Offset; Shift " << xyoff.first
0531 << ":" << xyoff.second << " WaferSize " << (waferSize_ + waferSepar_);
0532 #endif
0533 for (int u = -N; u <= N; ++u) {
0534 for (int v = -N; v <= N; ++v) {
0535 #ifdef EDM_ML_DEBUG
0536 int iu = std::abs(u);
0537 int iv = std::abs(v);
0538 #endif
0539 int nr = 2 * v;
0540 int nc = -2 * u + v;
0541 double xpos = xyoff.first + nc * r;
0542 double ypos = xyoff.second + nr * dy;
0543 const auto& corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false);
0544 #ifdef EDM_ML_DEBUG
0545 ++ntot;
0546 #endif
0547 int indx = HGCalWaferIndex::waferIndex((layer + firstLayer_), u, v, false);
0548 int type = HGCalWaferType::getType(indx, waferIndex_, waferProperty_);
0549 if (corner.first > 0 && type >= 0) {
0550 int copy = HGCalTypes::packTypeUV(type, u, v);
0551 if (layertype > 1)
0552 type += 3;
0553 #ifdef EDM_ML_DEBUG
0554 edm::LogVerbatim("HGCalGeom") << " DDHGCalHEFileAlgo: " << wafers_[type] << " number " << copy << " type "
0555 << type << " layer:u:v:indx " << (layer + firstLayer_) << ":" << u << ":" << v
0556 << ":" << indx;
0557 if (iu > ium)
0558 ium = iu;
0559 if (iv > ivm)
0560 ivm = iv;
0561 kount++;
0562 if (copies_.count(copy) == 0)
0563 copies_.insert(copy);
0564 #endif
0565 if (corner.first == (int)(HGCalParameters::k_CornerSize)) {
0566 #ifdef EDM_ML_DEBUG
0567 if (iu > iumAll)
0568 iumAll = iu;
0569 if (iv > ivmAll)
0570 ivmAll = iv;
0571 ++nin;
0572 #endif
0573 DDTranslation tran(xpos, ypos, 0.0);
0574 DDRotation rotation;
0575 DDName name = DDName(DDSplit(wafers_[type]).first, DDSplit(wafers_[type]).second);
0576 cpv.position(name, glog.ddname(), copy, tran, rotation);
0577 #ifdef EDM_ML_DEBUG
0578 ++ntype[type];
0579 edm::LogVerbatim("HGCalGeom") << " DDHGCalHEFileAlgo: " << name << " number " << copy << " type " << layertype
0580 << ":" << type << " positioned in " << glog.ddname() << " at " << tran
0581 << " with no rotation";
0582 #endif
0583 }
0584 }
0585 }
0586 }
0587 #ifdef EDM_ML_DEBUG
0588 edm::LogVerbatim("HGCalGeom") << "DDHGCalHEFileAlgo: Maximum # of u " << ium << ":" << iumAll << " # of v " << ivm
0589 << ":" << ivmAll << " and " << nin << ":" << kount << ":" << ntot << " wafers ("
0590 << ntype[0] << ":" << ntype[1] << ":" << ntype[2] << ":" << ntype[3] << ":" << ntype[4]
0591 << ":" << ntype[5] << ") for " << glog.ddname() << " R " << rin << ":" << rout;
0592 #endif
0593 }
0594
0595 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalHEFileAlgo, "hgcal:DDHGCalHEFileAlgo");