File indexing completed on 2025-03-29 02:43:08
0001
0002
0003
0004
0005
0006
0007 #include "DataFormats/Math/interface/angle_units.h"
0008 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0009 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0010 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0011 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0012 #include "DetectorDescription/Core/interface/DDMaterial.h"
0013 #include "DetectorDescription/Core/interface/DDSolid.h"
0014 #include "DetectorDescription/Core/interface/DDSplit.h"
0015 #include "DetectorDescription/Core/interface/DDTypes.h"
0016 #include "DetectorDescription/Core/interface/DDutils.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 #include "FWCore/PluginManager/interface/PluginFactory.h"
0019 #include "Geometry/HGCalCommonData/interface/HGCalCell.h"
0020 #include "Geometry/HGCalCommonData/interface/HGCalCassette.h"
0021 #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h"
0022 #include "Geometry/HGCalCommonData/interface/HGCalParameters.h"
0023 #include "Geometry/HGCalCommonData/interface/HGCalProperty.h"
0024 #include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
0025 #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h"
0026 #include "Geometry/HGCalCommonData/interface/HGCalWaferType.h"
0027
0028 #include <cmath>
0029 #include <memory>
0030 #include <sstream>
0031 #include <string>
0032 #include <unordered_set>
0033 #include <vector>
0034
0035
0036 using namespace angle_units::operators;
0037
0038 class DDHGCalSiliconRotatedCassette : public DDAlgorithm {
0039 public:
0040 DDHGCalSiliconRotatedCassette();
0041
0042 void initialize(const DDNumericArguments& nArgs,
0043 const DDVectorArguments& vArgs,
0044 const DDMapArguments& mArgs,
0045 const DDStringArguments& sArgs,
0046 const DDStringVectorArguments& vsArgs) override;
0047 void execute(DDCompactView& cpv) override;
0048
0049 protected:
0050 void constructLayers(const DDLogicalPart&, DDCompactView& cpv);
0051 void positionSensitive(const DDLogicalPart& glog, int layer, DDCompactView& cpv);
0052 void positionPassive(const DDLogicalPart& glog, int layer, int type, DDCompactView& cpv);
0053 void positionPassiveNew(const DDLogicalPart& glog, int layer, int type, DDCompactView& cpv);
0054
0055 private:
0056 HGCalGeomTools geomTools_;
0057 HGCalCassette cassette_;
0058
0059 static constexpr double tol1_ = 0.01;
0060 static constexpr double tol2_ = 0.00001;
0061
0062 int waferTypes_;
0063 int passiveTypes_;
0064 int facingTypes_;
0065 int orientationTypes_;
0066 int partialTypes_;
0067 int placeOffset_;
0068 int firstLayer_;
0069 int absorbMode_;
0070 int sensitiveMode_;
0071 int passiveMode_;
0072 double zMinBlock_;
0073 double waferSize_;
0074 double waferSepar_;
0075 int sectors_;
0076 int cassettes_;
0077 std::string rotstr_;
0078 std::vector<std::string> waferFull_;
0079 std::vector<std::string> waferPart_;
0080 std::vector<std::string> passiveAbsorb_;
0081 std::vector<std::string> passiveCool_;
0082 std::vector<std::string> materials_;
0083 std::vector<std::string> names_;
0084 std::vector<double> thick_;
0085 std::vector<int> copyNumber_;
0086 std::vector<int> layers_;
0087 std::vector<double> layerThick_;
0088 std::vector<int> layerType_;
0089 std::vector<int> layerSense_;
0090 std::vector<double> slopeB_;
0091 std::vector<double> zFrontB_;
0092 std::vector<double> rMinFront_;
0093 std::vector<double> slopeT_;
0094 std::vector<double> zFrontT_;
0095 std::vector<double> rMaxFront_;
0096 std::vector<int> layerOrient_;
0097 std::vector<int> waferIndex_;
0098 std::vector<int> waferProperty_;
0099 std::vector<int> waferLayerStart_;
0100 std::vector<double> cassetteShift_;
0101 std::string nameSpace_;
0102 std::unordered_set<int> copies_;
0103 double alpha_, cosAlpha_;
0104 };
0105
0106 DDHGCalSiliconRotatedCassette::DDHGCalSiliconRotatedCassette() {
0107 #ifdef EDM_ML_DEBUG
0108 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Creating an instance";
0109 #endif
0110 }
0111
0112 void DDHGCalSiliconRotatedCassette::initialize(const DDNumericArguments& nArgs,
0113 const DDVectorArguments& vArgs,
0114 const DDMapArguments&,
0115 const DDStringArguments& sArgs,
0116 const DDStringVectorArguments& vsArgs) {
0117 waferTypes_ = static_cast<int>(nArgs["WaferTypes"]);
0118 passiveTypes_ = static_cast<int>(nArgs["PassiveTypes"]);
0119 facingTypes_ = static_cast<int>(nArgs["FacingTypes"]);
0120 orientationTypes_ = static_cast<int>(nArgs["OrientationTypes"]);
0121 partialTypes_ = static_cast<int>(nArgs["PartialTypes"]);
0122 placeOffset_ = static_cast<int>(nArgs["PlaceOffset"]);
0123 #ifdef EDM_ML_DEBUG
0124 edm::LogVerbatim("HGCalGeom") << "Number of types of wafers: " << waferTypes_ << " passives: " << passiveTypes_
0125 << " facings: " << facingTypes_ << " Orientations: " << orientationTypes_
0126 << " PartialTypes: " << partialTypes_ << " PlaceOffset: " << placeOffset_;
0127 #endif
0128 firstLayer_ = static_cast<int>(nArgs["FirstLayer"]);
0129 absorbMode_ = static_cast<int>(nArgs["AbsorberMode"]);
0130 sensitiveMode_ = static_cast<int>(nArgs["SensitiveMode"]);
0131 passiveMode_ = static_cast<int>(nArgs["PassiveMode"]);
0132 #ifdef EDM_ML_DEBUG
0133 edm::LogVerbatim("HGCalGeom") << "First Layer " << firstLayer_ << " and "
0134 << "Absober:Sensitive mode " << absorbMode_ << ":" << sensitiveMode_ << ":"
0135 << passiveMode_;
0136 #endif
0137 zMinBlock_ = nArgs["zMinBlock"];
0138 waferSize_ = nArgs["waferSize"];
0139 waferSepar_ = nArgs["SensorSeparation"];
0140 sectors_ = static_cast<int>(nArgs["Sectors"]);
0141 cassettes_ = static_cast<int>(nArgs["Cassettes"]);
0142 alpha_ = (1._pi) / sectors_;
0143 cosAlpha_ = cos(alpha_);
0144 rotstr_ = sArgs["LayerRotation"];
0145 #ifdef EDM_ML_DEBUG
0146 edm::LogVerbatim("HGCalGeom") << "zStart " << zMinBlock_ << " wafer width " << waferSize_ << " separations "
0147 << waferSepar_ << " sectors " << sectors_ << ":" << convertRadToDeg(alpha_) << ":"
0148 << cosAlpha_ << " rotation matrix " << rotstr_ << " with " << cassettes_
0149 << " cassettes";
0150 #endif
0151 waferFull_ = vsArgs["WaferNamesFull"];
0152 waferPart_ = vsArgs["WaferNamesPartial"];
0153 #ifdef EDM_ML_DEBUG
0154 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << waferFull_.size() << " full and "
0155 << waferPart_.size() << " partial modules";
0156 unsigned int i1max = static_cast<unsigned int>(waferFull_.size());
0157 for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
0158 std::ostringstream st1;
0159 unsigned int i2 = std::min((i1 + 2), i1max);
0160 for (unsigned int i = i1; i < i2; ++i)
0161 st1 << " [" << i << "] " << waferFull_[i];
0162 edm::LogVerbatim("HGCalGeom") << st1.str();
0163 }
0164 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Partial Modules:";
0165 i1max = static_cast<unsigned int>(waferPart_.size());
0166 for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
0167 std::ostringstream st1;
0168 unsigned int i2 = std::min((i1 + 2), i1max);
0169 for (unsigned int i = i1; i < i2; ++i)
0170 st1 << " [" << i << "] " << waferPart_[i];
0171 edm::LogVerbatim("HGCalGeom") << st1.str();
0172 }
0173 #endif
0174 passiveAbsorb_ = vsArgs["PassiveNamesFull"];
0175 passiveCool_ = vsArgs["PassiveNamesPartial"];
0176 if ((passiveAbsorb_.size() == 1) && (passiveAbsorb_[0] == "NULL"))
0177 passiveAbsorb_.clear();
0178 if ((passiveCool_.size() == 1) && (passiveCool_[0] == "NULL"))
0179 passiveCool_.clear();
0180 #ifdef EDM_ML_DEBUG
0181 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << passiveAbsorb_.size() << " full and "
0182 << passiveCool_.size() << " partial passive modules";
0183 i1max = static_cast<unsigned int>(passiveAbsorb_.size());
0184 for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
0185 std::ostringstream st1;
0186 unsigned int i2 = std::min((i1 + 2), i1max);
0187 for (unsigned int i = i1; i < i2; ++i)
0188 st1 << " [" << i << "] " << passiveAbsorb_[i];
0189 edm::LogVerbatim("HGCalGeom") << st1.str();
0190 }
0191 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Partial Modules:";
0192 i1max = static_cast<unsigned int>(passiveCool_.size());
0193 for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
0194 std::ostringstream st1;
0195 unsigned int i2 = std::min((i1 + 2), i1max);
0196 for (unsigned int i = i1; i < i2; ++i)
0197 st1 << " [" << i << "] " << passiveCool_[i];
0198 edm::LogVerbatim("HGCalGeom") << st1.str();
0199 }
0200 #endif
0201 materials_ = vsArgs["MaterialNames"];
0202 names_ = vsArgs["VolumeNames"];
0203 thick_ = vArgs["Thickness"];
0204 copyNumber_.resize(materials_.size(), 1);
0205 #ifdef EDM_ML_DEBUG
0206 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << materials_.size() << " types of volumes";
0207 for (unsigned int i = 0; i < names_.size(); ++i)
0208 edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] << " of thickness " << thick_[i]
0209 << " filled with " << materials_[i] << " first copy number " << copyNumber_[i];
0210 #endif
0211 layers_ = dbl_to_int(vArgs["Layers"]);
0212 layerThick_ = vArgs["LayerThick"];
0213 #ifdef EDM_ML_DEBUG
0214 edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks";
0215 for (unsigned int i = 0; i < layers_.size(); ++i)
0216 edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick_[i] << " with " << layers_[i]
0217 << " layers";
0218 #endif
0219 layerType_ = dbl_to_int(vArgs["LayerType"]);
0220 layerSense_ = dbl_to_int(vArgs["LayerSense"]);
0221 layerOrient_ = dbl_to_int(vArgs["LayerTypes"]);
0222 for (unsigned int k = 0; k < layerOrient_.size(); ++k)
0223 layerOrient_[k] = HGCalTypes::layerType(layerOrient_[k]);
0224 #ifdef EDM_ML_DEBUG
0225 for (unsigned int i = 0; i < layerOrient_.size(); ++i)
0226 edm::LogVerbatim("HGCalGeom") << "LayerOrient [" << i << "] " << layerOrient_[i];
0227 #endif
0228 if (firstLayer_ > 0) {
0229 for (unsigned int i = 0; i < layerType_.size(); ++i) {
0230 if (layerSense_[i] > 0) {
0231 int ii = layerType_[i];
0232 copyNumber_[ii] = (layerSense_[i] == 1) ? firstLayer_ : (firstLayer_ + 1);
0233 #ifdef EDM_ML_DEBUG
0234 edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " << i << ":" << ii << " with "
0235 << materials_[ii] << " changed to " << copyNumber_[ii];
0236 #endif
0237 }
0238 }
0239 } else {
0240 firstLayer_ = 1;
0241 }
0242 #ifdef EDM_ML_DEBUG
0243 edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
0244 for (unsigned int i = 0; i < layerType_.size(); ++i)
0245 edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class "
0246 << layerSense_[i];
0247 #endif
0248 slopeB_ = vArgs["SlopeBottom"];
0249 zFrontB_ = vArgs["ZFrontBottom"];
0250 rMinFront_ = vArgs["RMinFront"];
0251 slopeT_ = vArgs["SlopeTop"];
0252 zFrontT_ = vArgs["ZFrontTop"];
0253 rMaxFront_ = vArgs["RMaxFront"];
0254 #ifdef EDM_ML_DEBUG
0255 for (unsigned int i = 0; i < slopeB_.size(); ++i)
0256 edm::LogVerbatim("HGCalGeom") << "Bottom Block [" << i << "] Zmin " << zFrontB_[i] << " Rmin " << rMinFront_[i]
0257 << " Slope " << slopeB_[i];
0258 for (unsigned int i = 0; i < slopeT_.size(); ++i)
0259 edm::LogVerbatim("HGCalGeom") << "Top Block [" << i << "] Zmin " << zFrontT_[i] << " Rmax " << rMaxFront_[i]
0260 << " Slope " << slopeT_[i];
0261 #endif
0262 waferIndex_ = dbl_to_int(vArgs["WaferIndex"]);
0263 waferProperty_ = dbl_to_int(vArgs["WaferProperties"]);
0264 waferLayerStart_ = dbl_to_int(vArgs["WaferLayerStart"]);
0265 cassetteShift_ = vArgs["CassetteShift"];
0266 #ifdef EDM_ML_DEBUG
0267 edm::LogVerbatim("HGCalGeom") << "waferProperties with " << waferIndex_.size() << " entries in "
0268 << waferLayerStart_.size() << " layers";
0269 for (unsigned int k = 0; k < waferLayerStart_.size(); ++k)
0270 edm::LogVerbatim("HGCalGeom") << "LayerStart[" << k << "] " << waferLayerStart_[k];
0271 for (unsigned int k = 0; k < waferIndex_.size(); ++k)
0272 edm::LogVerbatim("HGCalGeom") << "Wafer[" << k << "] " << waferIndex_[k] << " ("
0273 << HGCalWaferIndex::waferLayer(waferIndex_[k]) << ", "
0274 << HGCalWaferIndex::waferU(waferIndex_[k]) << ", "
0275 << HGCalWaferIndex::waferV(waferIndex_[k]) << ") : ("
0276 << HGCalProperty::waferThick(waferProperty_[k]) << ":"
0277 << HGCalProperty::waferPartial(waferProperty_[k]) << ":"
0278 << HGCalProperty::waferOrient(waferProperty_[k]) << ")";
0279 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << cassetteShift_.size()
0280 << " elements for cassette shifts";
0281 unsigned int j1max = cassetteShift_.size();
0282 for (unsigned int j1 = 0; j1 < j1max; j1 += 6) {
0283 std::ostringstream st1;
0284 unsigned int j2 = std::min((j1 + 6), j1max);
0285 for (unsigned int j = j1; j < j2; ++j)
0286 st1 << " [" << j << "] " << std::setw(9) << cassetteShift_[j];
0287 edm::LogVerbatim("HGCalGeom") << st1.str();
0288 }
0289 #endif
0290 nameSpace_ = DDCurrentNamespace::ns();
0291 #ifdef EDM_ML_DEBUG
0292 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: NameSpace " << nameSpace_ << ":";
0293 #endif
0294 cassette_.setParameter(cassettes_, cassetteShift_);
0295 }
0296
0297
0298
0299
0300 void DDHGCalSiliconRotatedCassette::execute(DDCompactView& cpv) {
0301 #ifdef EDM_ML_DEBUG
0302 edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalSiliconRotatedCassette...";
0303 copies_.clear();
0304 #endif
0305 constructLayers(parent(), cpv);
0306 #ifdef EDM_ML_DEBUG
0307 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << copies_.size()
0308 << " different wafer copy numbers";
0309 int k(0);
0310 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++k) {
0311 edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr);
0312 }
0313 copies_.clear();
0314 edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalSiliconRotatedCassette construction...";
0315 #endif
0316 }
0317
0318 void DDHGCalSiliconRotatedCassette::constructLayers(const DDLogicalPart& module, DDCompactView& cpv) {
0319 double zi(zMinBlock_);
0320 int laymin(0);
0321 #ifdef EDM_ML_DEBUG
0322 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Enters constructLayers with " << layers_.size()
0323 << " layers";
0324 #endif
0325 for (unsigned int i = 0; i < layers_.size(); i++) {
0326 double zo = zi + layerThick_[i];
0327 double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_);
0328 int laymax = laymin + layers_[i];
0329 double zz = zi;
0330 double thickTot(0);
0331 #ifdef EDM_ML_DEBUG
0332 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Section " << i << " Layers " << laymin << ":"
0333 << laymax << " zi " << zi;
0334 #endif
0335 for (int ly = laymin; ly < laymax; ++ly) {
0336 int ii = layerType_[ly];
0337 int copy = copyNumber_[ii];
0338 double hthick = 0.5 * thick_[ii];
0339 double rinB = HGCalGeomTools::radius(zo - tol1_, zFrontB_, rMinFront_, slopeB_);
0340 zz += hthick;
0341 thickTot += thick_[ii];
0342
0343 std::string name = names_[ii] + std::to_string(copy);
0344 #ifdef EDM_ML_DEBUG
0345 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Layer " << ly << ":" << ii << " Front " << zi
0346 << ", " << routF << " Back " << zo << ", " << rinB << " superlayer thickness "
0347 << layerThick_[i];
0348 #endif
0349 DDName matName(DDSplit(materials_[ii]).first, DDSplit(materials_[ii]).second);
0350 DDMaterial matter(matName);
0351 DDLogicalPart glog;
0352 if (layerSense_[ly] == 0) {
0353 std::vector<double> pgonZ, pgonRin, pgonRout;
0354 double rmax = routF * cosAlpha_ - tol1_;
0355 HGCalGeomTools::radius(zz - hthick,
0356 zz + hthick,
0357 zFrontB_,
0358 rMinFront_,
0359 slopeB_,
0360 zFrontT_,
0361 rMaxFront_,
0362 slopeT_,
0363 -layerSense_[ly],
0364 pgonZ,
0365 pgonRin,
0366 pgonRout);
0367 for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
0368 pgonZ[isec] -= zz;
0369 if (layerSense_[ly] == 0 || absorbMode_ == 0)
0370 pgonRout[isec] = rmax;
0371 else
0372 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
0373 }
0374 DDSolid solid =
0375 DDSolidFactory::polyhedra(DDName(name, nameSpace_), sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
0376 glog = DDLogicalPart(solid.ddname(), matter, solid);
0377 #ifdef EDM_ML_DEBUG
0378 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << solid.name() << " polyhedra of "
0379 << sectors_ << " sectors covering " << convertRadToDeg(-alpha_) << ":"
0380 << convertRadToDeg(-alpha_ + 2._pi) << " with " << pgonZ.size()
0381 << " sections and filled with " << matName;
0382 for (unsigned int k = 0; k < pgonZ.size(); ++k)
0383 edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] << ":" << pgonRout[k];
0384 #endif
0385 } else {
0386 int mode = (layerSense_[ly] > 0) ? sensitiveMode_ : absorbMode_;
0387 double rins = (mode < 1) ? rinB : HGCalGeomTools::radius(zz + hthick - tol1_, zFrontB_, rMinFront_, slopeB_);
0388 double routs = (mode < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_);
0389 DDSolid solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rins, routs, 0.0, 2._pi);
0390 glog = DDLogicalPart(solid.ddname(), matter, solid);
0391 #ifdef EDM_ML_DEBUG
0392 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << solid.name() << " Tubs made of "
0393 << matName << " of dimensions " << rinB << ":" << rins << ", " << routF << ":"
0394 << routs << ", " << hthick << ", 0.0, 360.0 and position " << glog.name()
0395 << " number " << copy << ":" << layerOrient_[copy - firstLayer_] << " Z " << zz;
0396 edm::LogVerbatim("HGCalGeom") << "POSITION: " << layerSense_[ly] << " PassiveMode " << passiveMode_;
0397 #endif
0398 if (layerSense_[ly] > 0) {
0399 positionSensitive(glog, (copy - firstLayer_), cpv);
0400 } else if (passiveMode_ > 0) {
0401 unsigned int num = (-layerSense_[ly] <= waferTypes_) ? passiveAbsorb_.size() : passiveCool_.size();
0402 if (num > 0)
0403 positionPassiveNew(glog, i, -layerSense_[ly], cpv);
0404
0405 } else {
0406 positionPassive(glog, (copy - firstLayer_), -layerSense_[ly], cpv);
0407 }
0408 }
0409 DDTranslation r1(0, 0, zz);
0410 DDRotation rot;
0411 #ifdef EDM_ML_DEBUG
0412 std::string rotName("Null");
0413 #endif
0414 if ((layerSense_[ly] != 0) && (layerOrient_[copy - firstLayer_] == HGCalTypes::WaferCenterR)) {
0415 rot = DDRotation(DDName(DDSplit(rotstr_).first, DDSplit(rotstr_).second));
0416 #ifdef EDM_ML_DEBUG
0417 rotName = rotstr_;
0418 #endif
0419 }
0420 cpv.position(glog, module, copy, r1, rot);
0421 int inc = ((layerSense_[ly] > 0) && (facingTypes_ > 1)) ? 2 : 1;
0422 copyNumber_[ii] = copy + inc;
0423 #ifdef EDM_ML_DEBUG
0424 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << glog.name() << " number " << copy
0425 << " positioned in " << module.name() << " at " << r1 << " with " << rotName
0426 << " rotation";
0427 #endif
0428 zz += hthick;
0429 }
0430 zi = zo;
0431 laymin = laymax;
0432
0433 if (std::abs(thickTot - layerThick_[i]) >= tol2_) {
0434 if (thickTot > layerThick_[i]) {
0435 edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot
0436 << ": thickness of all its components **** ERROR ****";
0437 } else {
0438 edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with "
0439 << thickTot << " of the components";
0440 }
0441 }
0442 }
0443 }
0444
0445
0446 void DDHGCalSiliconRotatedCassette::positionSensitive(const DDLogicalPart& glog, int layer, DDCompactView& cpv) {
0447 static const double sqrt3 = std::sqrt(3.0);
0448 int layercenter = layerOrient_[layer];
0449 int layertype = (layerOrient_[layer] == HGCalTypes::WaferCenterB) ? 1 : 0;
0450 int firstWafer = waferLayerStart_[layer];
0451 int lastWafer = ((layer + 1 < static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[layer + 1]
0452 : static_cast<int>(waferIndex_.size()));
0453 double delx = 0.5 * (waferSize_ + waferSepar_);
0454 double dely = 2.0 * delx / sqrt3;
0455 double dy = 0.75 * dely;
0456 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
0457 #ifdef EDM_ML_DEBUG
0458 int ium(0), ivm(0), kount(0);
0459 std::vector<int> ntype(3, 0);
0460 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: PositionSensitive layer " << layer << " r " << delx
0461 << " R " << dely << " dy " << dy << " Shift " << xyoff.first << ":" << xyoff.second
0462 << " WaferSize " << (waferSize_ + waferSepar_) << " index " << firstWafer << ":"
0463 << (lastWafer - 1) << " Layer Center " << layercenter << ":" << layertype;
0464 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << glog.ddname() << " r " << delx << " R " << dely
0465 << " dy " << dy << " Shift " << xyoff.first << ":" << xyoff.second << " WaferSize "
0466 << (waferSize_ + waferSepar_) << " index " << firstWafer << ":" << (lastWafer - 1)
0467 << " Layer Center " << layercenter << ":" << layertype;
0468 #endif
0469 for (int k = firstWafer; k < lastWafer; ++k) {
0470 int u = HGCalWaferIndex::waferU(waferIndex_[k]);
0471 int v = HGCalWaferIndex::waferV(waferIndex_[k]);
0472 #ifdef EDM_ML_DEBUG
0473 int iu = std::abs(u);
0474 int iv = std::abs(v);
0475 #endif
0476 int nr = 2 * v;
0477 int nc = -2 * u + v;
0478 int type = HGCalProperty::waferThick(waferProperty_[k]);
0479 int part = HGCalProperty::waferPartial(waferProperty_[k]);
0480 int orien = HGCalProperty::waferOrient(waferProperty_[k]);
0481 int cassette = HGCalProperty::waferCassette(waferProperty_[k]);
0482 int place = HGCalCell::cellPlacementIndex(1, layertype, orien);
0483 auto cshift = cassette_.getShift(layer + 1, -1, cassette);
0484 double xpos = xyoff.first - cshift.first + nc * delx;
0485 double ypos = xyoff.second + cshift.second + nr * dy;
0486 #ifdef EDM_ML_DEBUG
0487 double xorig = xyoff.first + nc * delx;
0488 double yorig = xyoff.second + nr * dy;
0489 double angle = std::atan2(yorig, xorig);
0490 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Wafer: layer " << layer + 1 << " cassette "
0491 << cassette << " Shift " << cshift.first << ":" << cshift.second << " Original "
0492 << xorig << ":" << yorig << ":" << convertRadToDeg(angle) << " Final " << xpos << ":"
0493 << ypos << " u|v " << u << ":" << v << " type|part|orient|place " << type << ":"
0494 << part << ":" << orien << ":" << place;
0495 #endif
0496 std::string wafer;
0497 int i(999);
0498 if (part == HGCalTypes::WaferFull) {
0499 i = type * facingTypes_ * orientationTypes_ + place - placeOffset_;
0500 #ifdef EDM_ML_DEBUG
0501 edm::LogVerbatim("HGCalGeom") << "facitype " << facingTypes_ << ":" << orientationTypes_ << ":" << placeOffset_
0502 << " i " << i << ":" << waferFull_.size();
0503 edm::LogVerbatim("HGCalGeom") << " layertype:type:part:orien:cassette:place:offsets:ind " << layertype << ":"
0504 << type << ":" << part << ":" << orien << ":" << cassette << ":" << place << ":"
0505 << placeOffset_ << ":" << facingTypes_ << ":" << orientationTypes_ << " wafer " << i
0506 << ":" << waferFull_.size();
0507 #endif
0508 wafer = waferFull_[i];
0509 } else {
0510 int partoffset = (part >= HGCalTypes::WaferHDTop) ? HGCalTypes::WaferPartHDOffset : HGCalTypes::WaferPartLDOffset;
0511 i = (part - partoffset) * facingTypes_ * orientationTypes_ +
0512 HGCalTypes::WaferTypeOffset[type] * facingTypes_ * orientationTypes_ + place - placeOffset_;
0513 #ifdef EDM_ML_DEBUG
0514 edm::LogVerbatim("HGCalGeom") << " layertype:type:part:orien:cassette:place:offsets:ind " << layertype << ":"
0515 << type << ":" << part << ":" << orien << ":" << cassette << ":" << place << ":"
0516 << partoffset << ":" << HGCalTypes::WaferTypeOffset[type] << ":" << i << ":"
0517 << waferPart_.size();
0518 #endif
0519 wafer = waferPart_[i];
0520 }
0521 int copy = HGCalTypes::packTypeUV(type, u, v);
0522 #ifdef EDM_ML_DEBUG
0523 edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: Layer "
0524 << HGCalWaferIndex::waferLayer(waferIndex_[k]) << " Wafer " << wafer << " number "
0525 << copy << " type:part:orien:place:ind " << type << ":" << part << ":" << orien << ":"
0526 << place << ":" << i << " layer:u:v:indx " << (layer + firstLayer_) << ":" << u << ":"
0527 << v << " pos " << xpos << ":" << ypos;
0528 if (iu > ium)
0529 ium = iu;
0530 if (iv > ivm)
0531 ivm = iv;
0532 kount++;
0533 if (copies_.count(copy) == 0)
0534 copies_.insert(copy);
0535 #endif
0536 DDTranslation tran(xpos, ypos, 0.0);
0537 DDRotation rotation;
0538 DDName name = DDName(DDSplit(wafer).first, DDSplit(wafer).second);
0539 cpv.position(name, glog.ddname(), copy, tran, rotation);
0540 #ifdef EDM_ML_DEBUG
0541 ++ntype[type];
0542 edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: " << name << " number " << copy << " type "
0543 << layertype << ":" << type << " positioned in " << glog.ddname() << " at " << tran
0544 << " with no rotation";
0545 #endif
0546 }
0547 #ifdef EDM_ML_DEBUG
0548 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Maximum # of u " << ium << " # of v " << ivm
0549 << " and " << kount << " passives (" << ntype[0] << ":" << ntype[1] << ":" << ntype[2]
0550 << ") for " << glog.ddname();
0551 #endif
0552 }
0553
0554
0555 void DDHGCalSiliconRotatedCassette::positionPassive(const DDLogicalPart& glog,
0556 int layer,
0557 int absType,
0558 DDCompactView& cpv) {
0559 #ifdef EDM_ML_DEBUG
0560 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: positionPassiveAbsorber is called";
0561 #endif
0562 static const double sqrt3 = std::sqrt(3.0);
0563 int layercenter = layerOrient_[layer];
0564 int layertype = (layerOrient_[layer] == HGCalTypes::WaferCenterB) ? 1 : 0;
0565 int firstWafer = waferLayerStart_[layer];
0566 int lastWafer = ((layer + 1 < static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[layer + 1]
0567 : static_cast<int>(waferIndex_.size()));
0568 double delx = 0.5 * (waferSize_ + waferSepar_);
0569 double dely = 2.0 * delx / sqrt3;
0570 double dy = 0.75 * dely;
0571 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
0572 #ifdef EDM_ML_DEBUG
0573 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: PositionPassive Layer " << layer << " LayerCenter "
0574 << layercenter << ":" << layertype << " r " << delx << " R " << dely << " dy " << dy
0575 << " Shift " << xyoff.first << ":" << xyoff.second << " WaferSize "
0576 << (waferSize_ + waferSepar_) << " index " << firstWafer << ":" << (lastWafer - 1);
0577 int ium(0), ivm(0), kount(0);
0578 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << glog.ddname() << " r " << delx << " R " << dely
0579 << " dy " << dy << " Shift " << xyoff.first << ":" << xyoff.second << " WaferSize "
0580 << (waferSize_ + waferSepar_) << " index " << firstWafer << ":" << (lastWafer - 1)
0581 << " Layer Center " << layercenter << ":" << layertype;
0582 #endif
0583 for (int k = firstWafer; k < lastWafer; ++k) {
0584 int u = HGCalWaferIndex::waferU(waferIndex_[k]);
0585 int v = HGCalWaferIndex::waferV(waferIndex_[k]);
0586 #ifdef EDM_ML_DEBUG
0587 int iu = std::abs(u);
0588 int iv = std::abs(v);
0589 #endif
0590 int nr = 2 * v;
0591 int nc = -2 * u + v;
0592 int part = HGCalProperty::waferPartial(waferProperty_[k]);
0593 int orien = HGCalProperty::waferOrient(waferProperty_[k]);
0594 int cassette = HGCalProperty::waferCassette(waferProperty_[k]);
0595 int place = HGCalCell::cellPlacementIndex(1, layertype, orien);
0596 auto cshift = cassette_.getShift(layer + 1, -1, cassette);
0597 double xpos = xyoff.first - cshift.first + nc * delx;
0598 double ypos = xyoff.second + cshift.second + nr * dy;
0599 #ifdef EDM_ML_DEBUG
0600 double xorig = xyoff.first + nc * delx;
0601 double yorig = xyoff.second + nr * dy;
0602 double angle = std::atan2(yorig, xorig);
0603 int type = HGCalProperty::waferThick(waferProperty_[k]);
0604 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive: layer " << layer + 1 << " cassette "
0605 << cassette << " Shift " << cshift.first << ":" << cshift.second << " Original "
0606 << xorig << ":" << yorig << ":" << convertRadToDeg(angle) << " Final " << xpos << ":"
0607 << ypos << " u|v " << u << ":" << v << " type|part|orient" << type << ":" << part
0608 << ":" << orien;
0609 #endif
0610 std::string passive;
0611 int i(999);
0612 if (part == HGCalTypes::WaferFull) {
0613 i = absType - 1;
0614 passive = passiveAbsorb_[i];
0615 #ifdef EDM_ML_DEBUG
0616 edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:offsets:ind " << layertype << ":"
0617 << absType << ":" << part << ":" << orien << ":" << cassette << ":"
0618 << ":" << partialTypes_ << ":" << orientationTypes_ << " passive " << i << ":"
0619 << passive;
0620 #endif
0621 } else {
0622 int partoffset = (part >= HGCalTypes::WaferHDTop)
0623 ? HGCalTypes::WaferPartHDOffset
0624 : (HGCalTypes::WaferPartLDOffset - HGCalTypes::WaferTypeOffset[1]);
0625 i = (part - partoffset) * facingTypes_ * orientationTypes_ +
0626 (absType - 1) * facingTypes_ * orientationTypes_ * partialTypes_ + place - placeOffset_;
0627 #ifdef EDM_ML_DEBUG
0628 edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:3Types:offset:ind " << layertype << ":"
0629 << absType << ":" << part << ":" << orien << ":" << cassette << ":" << partialTypes_
0630 << ":" << facingTypes_ << ":" << orientationTypes_ << ":" << partoffset << ":" << i
0631 << ":" << passiveCool_.size();
0632 #endif
0633 passive = passiveCool_[i];
0634 }
0635 int copy = HGCalTypes::packTypeUV(absType, u, v);
0636 #ifdef EDM_ML_DEBUG
0637 edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: Layer "
0638 << HGCalWaferIndex::waferLayer(waferIndex_[k]) << " Passive " << passive << " number "
0639 << copy << " type:part:orien:place:ind " << type << ":" << part << ":" << orien << ":"
0640 << place << ":" << i << " layer:u:v:indx " << (layer + firstLayer_) << ":" << u << ":"
0641 << v << " pos " << xpos << ":" << ypos;
0642 if (iu > ium)
0643 ium = iu;
0644 if (iv > ivm)
0645 ivm = iv;
0646 kount++;
0647 #endif
0648 DDTranslation tran(xpos, ypos, 0.0);
0649 DDRotation rotation;
0650 DDName name = DDName(DDSplit(passive).first, DDSplit(passive).second);
0651 cpv.position(name, glog.ddname(), copy, tran, rotation);
0652 #ifdef EDM_ML_DEBUG
0653 edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: " << name << " number " << copy << " type "
0654 << layertype << ":" << type << " positioned in " << glog.ddname() << " at " << tran
0655 << " with no rotation";
0656 #endif
0657 }
0658 #ifdef EDM_ML_DEBUG
0659 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Maximum # of u " << ium << " # of v " << ivm
0660 << " and " << kount << " passives for " << glog.ddname();
0661 #endif
0662 }
0663
0664
0665 void DDHGCalSiliconRotatedCassette::positionPassiveNew(const DDLogicalPart& glog,
0666 int layer,
0667 int absType,
0668 DDCompactView& cpv) {
0669 #ifdef EDM_ML_DEBUG
0670 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: positionPassiveNew is called";
0671 int kount(0);
0672 #endif
0673 bool type = (absType <= waferTypes_);
0674 int num = type ? (passiveAbsorb_.size() / (cassettes_ * layers_.size()))
0675 : (passiveCool_.size() / (cassettes_ * layers_.size()));
0676 #ifdef EDM_ML_DEBUG
0677 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Type " << type << " number per cassette " << num;
0678 #endif
0679 for (int k = 0; k < cassettes_; ++k) {
0680 double xpos(0), ypos(0), zpos(0);
0681 for (int n = 0; n < num; ++n) {
0682 int i1 = num * k + n;
0683 int i2 = num * layer * cassettes_ + i1;
0684 #ifdef EDM_ML_DEBUG
0685 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive2: layer " << layer + 1 << " cassette "
0686 << " PassiveIndex " << i1 << ":" << i2 << ":" << passiveAbsorb_.size() << ":"
0687 << passiveCool_.size();
0688 #endif
0689 std::string passive = (type) ? passiveAbsorb_[i2] : passiveCool_[i2];
0690 #ifdef EDM_ML_DEBUG
0691 edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: Passive2 " << passive << " number " << i2
0692 << " pos " << xpos << ":" << ypos << ":" << zpos;
0693 kount++;
0694 #endif
0695 DDTranslation tran(xpos, ypos, zpos);
0696 DDRotation rotation;
0697 DDName name = DDName(DDSplit(passive).first, DDSplit(passive).second);
0698 cpv.position(name, glog.ddname(), i2, tran, rotation);
0699 #ifdef EDM_ML_DEBUG
0700 edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: " << name << " number " << i2
0701 << " positioned in " << glog.ddname() << " at " << tran << " with no rotation";
0702 #endif
0703 }
0704 }
0705 #ifdef EDM_ML_DEBUG
0706 edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << kount << " passives of type " << absType
0707 << " for " << glog.ddname();
0708 #endif
0709 }
0710
0711 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalSiliconRotatedCassette, "hgcal:DDHGCalSiliconRotatedCassette");