Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:00

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDHGCalSiliconRotatedModule.cc
0003 // Description: Geometry factory class for HGCal (EE and HESil) using
0004 //              information from the file
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 //#define EDM_ML_DEBUG
0036 using namespace angle_units::operators;
0037 
0038 class DDHGCalSiliconRotatedModule : public DDAlgorithm {
0039 public:
0040   DDHGCalSiliconRotatedModule();
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 
0053 private:
0054   HGCalGeomTools geomTools_;
0055   HGCalCassette cassette_;
0056 
0057   static constexpr double tol1_ = 0.01;
0058   static constexpr double tol2_ = 0.00001;
0059 
0060   int waferTypes_;                      // Number of wafer types
0061   int facingTypes_;                     // Types of facings of modules toward IP
0062   int orientationTypes_;                // Number of wafer orienations
0063   int placeOffset_;                     // Offset for placement
0064   int firstLayer_;                      // Copy # of the first sensitive layer
0065   int absorbMode_;                      // Absorber mode
0066   int sensitiveMode_;                   // Sensitive mode
0067   double zMinBlock_;                    // Starting z-value of the block
0068   double waferSize_;                    // Width of the wafer
0069   double waferSepar_;                   // Sensor separation
0070   int sectors_;                         // Sectors
0071   int cassettes_;                       // Cassettes
0072   std::string rotstr_;                  // Rotation matrix (if needed)
0073   std::vector<std::string> waferFull_;  // Names of full wafer modules
0074   std::vector<std::string> waferPart_;  // Names of partial wafer modules
0075   std::vector<std::string> materials_;  // names of materials
0076   std::vector<std::string> names_;      // Names of volumes
0077   std::vector<double> thick_;           // Thickness of the material
0078   std::vector<int> copyNumber_;         // Initial copy numbers
0079   std::vector<int> layers_;             // Number of layers in a section
0080   std::vector<double> layerThick_;      // Thickness of each section
0081   std::vector<int> layerType_;          // Type of the layer
0082   std::vector<int> layerSense_;         // Content of a layer (sensitive?)
0083   std::vector<double> slopeB_;          // Slope at the lower R
0084   std::vector<double> zFrontB_;         // Starting Z values for the slopes
0085   std::vector<double> rMinFront_;       // Corresponding rMin's
0086   std::vector<double> slopeT_;          // Slopes at the larger R
0087   std::vector<double> zFrontT_;         // Starting Z values for the slopes
0088   std::vector<double> rMaxFront_;       // Corresponding rMax's
0089   std::vector<int> layerOrient_;        // Layer orientation (Centering, rotations..)
0090   std::vector<int> waferIndex_;         // Wafer index for the types
0091   std::vector<int> waferProperty_;      // Wafer property
0092   std::vector<int> waferLayerStart_;    // Index of wafers in each layer
0093   std::vector<double> cassetteShift_;   // Shifts of the cassetes
0094   std::string nameSpace_;               // Namespace of this and ALL sub-parts
0095   std::unordered_set<int> copies_;      // List of copy #'s
0096   double alpha_, cosAlpha_;
0097 };
0098 
0099 DDHGCalSiliconRotatedModule::DDHGCalSiliconRotatedModule() {
0100 #ifdef EDM_ML_DEBUG
0101   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: Creating an instance";
0102 #endif
0103 }
0104 
0105 void DDHGCalSiliconRotatedModule::initialize(const DDNumericArguments& nArgs,
0106                                              const DDVectorArguments& vArgs,
0107                                              const DDMapArguments&,
0108                                              const DDStringArguments& sArgs,
0109                                              const DDStringVectorArguments& vsArgs) {
0110   waferTypes_ = static_cast<int>(nArgs["WaferTypes"]);
0111   facingTypes_ = static_cast<int>(nArgs["FacingTypes"]);
0112   orientationTypes_ = static_cast<int>(nArgs["OrientationTypes"]);
0113   placeOffset_ = static_cast<int>(nArgs["PlaceOffset"]);
0114 #ifdef EDM_ML_DEBUG
0115   edm::LogVerbatim("HGCalGeom") << "Number of types of wafers: " << waferTypes_ << " facings: " << facingTypes_
0116                                 << " Orientations: " << orientationTypes_ << " PlaceOffset: " << placeOffset_;
0117 #endif
0118   firstLayer_ = static_cast<int>(nArgs["FirstLayer"]);
0119   absorbMode_ = static_cast<int>(nArgs["AbsorberMode"]);
0120   sensitiveMode_ = static_cast<int>(nArgs["SensitiveMode"]);
0121 #ifdef EDM_ML_DEBUG
0122   edm::LogVerbatim("HGCalGeom") << "First Layer " << firstLayer_ << " and "
0123                                 << "Absober:Sensitive mode " << absorbMode_ << ":" << sensitiveMode_;
0124 #endif
0125   zMinBlock_ = nArgs["zMinBlock"];
0126   waferSize_ = nArgs["waferSize"];
0127   waferSepar_ = nArgs["SensorSeparation"];
0128   sectors_ = static_cast<int>(nArgs["Sectors"]);
0129   cassettes_ = static_cast<int>(nArgs["Cassettes"]);
0130   alpha_ = (1._pi) / sectors_;
0131   cosAlpha_ = cos(alpha_);
0132   rotstr_ = sArgs["LayerRotation"];
0133 #ifdef EDM_ML_DEBUG
0134   edm::LogVerbatim("HGCalGeom") << "zStart " << zMinBlock_ << " wafer width " << waferSize_ << " separations "
0135                                 << waferSepar_ << " sectors " << sectors_ << ":" << convertRadToDeg(alpha_) << ":"
0136                                 << cosAlpha_ << " rotation matrix " << rotstr_ << " with " << cassettes_
0137                                 << " cassettes";
0138 #endif
0139   waferFull_ = vsArgs["WaferNamesFull"];
0140   waferPart_ = vsArgs["WaferNamesPartial"];
0141 #ifdef EDM_ML_DEBUG
0142   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: " << waferFull_.size() << " full and "
0143                                 << waferPart_.size() << " partial modules\nDDHGCalSiliconRotatedModule:Full Modules:";
0144   unsigned int i1max = static_cast<unsigned int>(waferFull_.size());
0145   for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
0146     std::ostringstream st1;
0147     unsigned int i2 = std::min((i1 + 2), i1max);
0148     for (unsigned int i = i1; i < i2; ++i)
0149       st1 << " [" << i << "] " << waferFull_[i];
0150     edm::LogVerbatim("HGCalGeom") << st1.str();
0151   }
0152   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: Partial Modules:";
0153   i1max = static_cast<unsigned int>(waferPart_.size());
0154   for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
0155     std::ostringstream st1;
0156     unsigned int i2 = std::min((i1 + 2), i1max);
0157     for (unsigned int i = i1; i < i2; ++i)
0158       st1 << " [" << i << "] " << waferPart_[i];
0159     edm::LogVerbatim("HGCalGeom") << st1.str();
0160   }
0161 #endif
0162   materials_ = vsArgs["MaterialNames"];
0163   names_ = vsArgs["VolumeNames"];
0164   thick_ = vArgs["Thickness"];
0165   copyNumber_.resize(materials_.size(), 1);
0166 #ifdef EDM_ML_DEBUG
0167   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: " << materials_.size() << " types of volumes";
0168   for (unsigned int i = 0; i < names_.size(); ++i)
0169     edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] << " of thickness " << thick_[i]
0170                                   << " filled with " << materials_[i] << " first copy number " << copyNumber_[i];
0171 #endif
0172   layers_ = dbl_to_int(vArgs["Layers"]);
0173   layerThick_ = vArgs["LayerThick"];
0174 #ifdef EDM_ML_DEBUG
0175   edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks";
0176   for (unsigned int i = 0; i < layers_.size(); ++i)
0177     edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick_[i] << " with " << layers_[i]
0178                                   << " layers";
0179 #endif
0180   layerType_ = dbl_to_int(vArgs["LayerType"]);
0181   layerSense_ = dbl_to_int(vArgs["LayerSense"]);
0182   layerOrient_ = dbl_to_int(vArgs["LayerTypes"]);
0183   for (unsigned int k = 0; k < layerOrient_.size(); ++k)
0184     layerOrient_[k] = HGCalTypes::layerType(layerOrient_[k]);
0185 #ifdef EDM_ML_DEBUG
0186   for (unsigned int i = 0; i < layerOrient_.size(); ++i)
0187     edm::LogVerbatim("HGCalGeom") << "LayerTypes [" << i << "] " << layerOrient_[i];
0188 #endif
0189   if (firstLayer_ > 0) {
0190     for (unsigned int i = 0; i < layerType_.size(); ++i) {
0191       if (layerSense_[i] > 0) {
0192         int ii = layerType_[i];
0193         copyNumber_[ii] = (layerSense_[i] == 1) ? firstLayer_ : (firstLayer_ + 1);
0194 #ifdef EDM_ML_DEBUG
0195         edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " << i << ":" << ii << " with "
0196                                       << materials_[ii] << " changed to " << copyNumber_[ii];
0197 #endif
0198       }
0199     }
0200   } else {
0201     firstLayer_ = 1;
0202   }
0203 #ifdef EDM_ML_DEBUG
0204   edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
0205   for (unsigned int i = 0; i < layerType_.size(); ++i)
0206     edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class "
0207                                   << layerSense_[i];
0208 #endif
0209   slopeB_ = vArgs["SlopeBottom"];
0210   zFrontB_ = vArgs["ZFrontBottom"];
0211   rMinFront_ = vArgs["RMinFront"];
0212   slopeT_ = vArgs["SlopeTop"];
0213   zFrontT_ = vArgs["ZFrontTop"];
0214   rMaxFront_ = vArgs["RMaxFront"];
0215 #ifdef EDM_ML_DEBUG
0216   for (unsigned int i = 0; i < slopeB_.size(); ++i)
0217     edm::LogVerbatim("HGCalGeom") << "Bottom Block [" << i << "] Zmin " << zFrontB_[i] << " Rmin " << rMinFront_[i]
0218                                   << " Slope " << slopeB_[i];
0219   for (unsigned int i = 0; i < slopeT_.size(); ++i)
0220     edm::LogVerbatim("HGCalGeom") << "Top Block [" << i << "] Zmin " << zFrontT_[i] << " Rmax " << rMaxFront_[i]
0221                                   << " Slope " << slopeT_[i];
0222 #endif
0223   waferIndex_ = dbl_to_int(vArgs["WaferIndex"]);
0224   waferProperty_ = dbl_to_int(vArgs["WaferProperties"]);
0225   waferLayerStart_ = dbl_to_int(vArgs["WaferLayerStart"]);
0226   cassetteShift_ = vArgs["CassetteShift"];
0227 #ifdef EDM_ML_DEBUG
0228   edm::LogVerbatim("HGCalGeom") << "waferProperties with " << waferIndex_.size() << " entries in "
0229                                 << waferLayerStart_.size() << " layers";
0230   for (unsigned int k = 0; k < waferLayerStart_.size(); ++k)
0231     edm::LogVerbatim("HGCalGeom") << "LayerStart[" << k << "] " << waferLayerStart_[k];
0232   for (unsigned int k = 0; k < waferIndex_.size(); ++k)
0233     edm::LogVerbatim("HGCalGeom") << "Wafer[" << k << "] " << waferIndex_[k] << " ("
0234                                   << HGCalWaferIndex::waferLayer(waferIndex_[k]) << ", "
0235                                   << HGCalWaferIndex::waferU(waferIndex_[k]) << ", "
0236                                   << HGCalWaferIndex::waferV(waferIndex_[k]) << ") : ("
0237                                   << HGCalProperty::waferThick(waferProperty_[k]) << ":"
0238                                   << HGCalProperty::waferPartial(waferProperty_[k]) << ":"
0239                                   << HGCalProperty::waferOrient(waferProperty_[k]) << ")";
0240   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: " << cassetteShift_.size()
0241                                 << " elements for cassette shifts";
0242   unsigned int j1max = cassetteShift_.size();
0243   for (unsigned int j1 = 0; j1 < j1max; j1 += 6) {
0244     std::ostringstream st1;
0245     unsigned int j2 = std::min((j1 + 6), j1max);
0246     for (unsigned int j = j1; j < j2; ++j)
0247       st1 << " [" << j << "] " << std::setw(9) << cassetteShift_[j];
0248     edm::LogVerbatim("HGCalGeom") << st1.str();
0249   }
0250 #endif
0251   nameSpace_ = DDCurrentNamespace::ns();
0252 #ifdef EDM_ML_DEBUG
0253   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: NameSpace " << nameSpace_ << ":";
0254 #endif
0255   cassette_.setParameter(cassettes_, cassetteShift_);
0256 }
0257 
0258 ////////////////////////////////////////////////////////////////////
0259 // DDHGCalSiliconRotatedModule methods...
0260 ////////////////////////////////////////////////////////////////////
0261 
0262 void DDHGCalSiliconRotatedModule::execute(DDCompactView& cpv) {
0263 #ifdef EDM_ML_DEBUG
0264   edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalSiliconRotatedModule...";
0265   copies_.clear();
0266 #endif
0267   constructLayers(parent(), cpv);
0268 #ifdef EDM_ML_DEBUG
0269   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: " << copies_.size() << " different wafer copy numbers";
0270   int k(0);
0271   for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++k) {
0272     edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr);
0273   }
0274   copies_.clear();
0275   edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalSiliconRotatedModule construction...";
0276 #endif
0277 }
0278 
0279 void DDHGCalSiliconRotatedModule::constructLayers(const DDLogicalPart& module, DDCompactView& cpv) {
0280   double zi(zMinBlock_);
0281   int laymin(0);
0282   for (unsigned int i = 0; i < layers_.size(); i++) {
0283     double zo = zi + layerThick_[i];
0284     double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_);
0285     int laymax = laymin + layers_[i];
0286     double zz = zi;
0287     double thickTot(0);
0288     for (int ly = laymin; ly < laymax; ++ly) {
0289       int ii = layerType_[ly];
0290       int copy = copyNumber_[ii];
0291       double hthick = 0.5 * thick_[ii];
0292       double rinB = HGCalGeomTools::radius(zo - tol1_, zFrontB_, rMinFront_, slopeB_);
0293       zz += hthick;
0294       thickTot += thick_[ii];
0295 
0296       std::string name = names_[ii] + std::to_string(copy);
0297 #ifdef EDM_ML_DEBUG
0298       edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: Layer " << ly << ":" << ii << " Front " << zi
0299                                     << ", " << routF << " Back " << zo << ", " << rinB << " superlayer thickness "
0300                                     << layerThick_[i];
0301 #endif
0302       DDName matName(DDSplit(materials_[ii]).first, DDSplit(materials_[ii]).second);
0303       DDMaterial matter(matName);
0304       DDLogicalPart glog;
0305       if (layerSense_[ly] < 1) {
0306         std::vector<double> pgonZ, pgonRin, pgonRout;
0307         double rmax = routF * cosAlpha_ - tol1_;
0308         HGCalGeomTools::radius(zz - hthick,
0309                                zz + hthick,
0310                                zFrontB_,
0311                                rMinFront_,
0312                                slopeB_,
0313                                zFrontT_,
0314                                rMaxFront_,
0315                                slopeT_,
0316                                -layerSense_[ly],
0317                                pgonZ,
0318                                pgonRin,
0319                                pgonRout);
0320         for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
0321           pgonZ[isec] -= zz;
0322           if (layerSense_[ly] == 0 || absorbMode_ == 0)
0323             pgonRout[isec] = rmax;
0324           else
0325             pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
0326         }
0327         DDSolid solid =
0328             DDSolidFactory::polyhedra(DDName(name, nameSpace_), sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
0329         glog = DDLogicalPart(solid.ddname(), matter, solid);
0330 #ifdef EDM_ML_DEBUG
0331         edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: " << solid.name() << " polyhedra of " << sectors_
0332                                       << " sectors covering " << convertRadToDeg(-alpha_) << ":"
0333                                       << convertRadToDeg(-alpha_ + 2._pi) << " with " << pgonZ.size()
0334                                       << " sections and filled with " << matName;
0335         for (unsigned int k = 0; k < pgonZ.size(); ++k)
0336           edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] << ":" << pgonRout[k];
0337 #endif
0338       } else {
0339         double rins =
0340             (sensitiveMode_ < 1) ? rinB : HGCalGeomTools::radius(zz + hthick - tol1_, zFrontB_, rMinFront_, slopeB_);
0341         double routs =
0342             (sensitiveMode_ < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_);
0343         DDSolid solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rins, routs, 0.0, 2._pi);
0344         glog = DDLogicalPart(solid.ddname(), matter, solid);
0345 #ifdef EDM_ML_DEBUG
0346         edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: " << solid.name() << " Tubs made of " << matName
0347                                       << " of dimensions " << rinB << ":" << rins << ", " << routF << ":" << routs
0348                                       << ", " << hthick << ", 0.0, 360.0 and position " << glog.name() << " number "
0349                                       << copy << ":" << layerOrient_[copy - firstLayer_];
0350 #endif
0351         positionSensitive(glog, (copy - firstLayer_), cpv);
0352       }
0353       DDTranslation r1(0, 0, zz);
0354       DDRotation rot;
0355 #ifdef EDM_ML_DEBUG
0356       std::string rotName("Null");
0357 #endif
0358       if ((layerSense_[ly] > 0) && (layerOrient_[copy - firstLayer_] == HGCalTypes::WaferCenterR)) {
0359         rot = DDRotation(DDName(DDSplit(rotstr_).first, DDSplit(rotstr_).second));
0360 #ifdef EDM_ML_DEBUG
0361         rotName = rotstr_;
0362 #endif
0363       }
0364       cpv.position(glog, module, copy, r1, rot);
0365       int inc = ((layerSense_[ly] > 0) && (facingTypes_ > 1)) ? 2 : 1;
0366       copyNumber_[ii] = copy + inc;
0367 #ifdef EDM_ML_DEBUG
0368       edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: " << glog.name() << " number " << copy
0369                                     << " positioned in " << module.name() << " at " << r1 << " with " << rotName
0370                                     << " rotation";
0371 #endif
0372       zz += hthick;
0373     }  // End of loop over layers in a block
0374     zi = zo;
0375     laymin = laymax;
0376     // Make consistency check of all the partitions of the block
0377     if (std::abs(thickTot - layerThick_[i]) >= tol2_) {
0378       if (thickTot > layerThick_[i]) {
0379         edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot
0380                                    << ": thickness of all its components **** ERROR ****";
0381       } else {
0382         edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with "
0383                                      << thickTot << " of the components";
0384       }
0385     }
0386   }  // End of loop over blocks
0387 }
0388 
0389 // Position the silicon modules
0390 void DDHGCalSiliconRotatedModule::positionSensitive(const DDLogicalPart& glog, int layer, DDCompactView& cpv) {
0391   static const double sqrt3 = std::sqrt(3.0);
0392   int layercenter = layerOrient_[layer];
0393   int layertype = (layerOrient_[layer] == HGCalTypes::WaferCenterB) ? 1 : 0;
0394   int firstWafer = waferLayerStart_[layer];
0395   int lastWafer = ((layer + 1 < static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[layer + 1]
0396                                                                            : static_cast<int>(waferIndex_.size()));
0397   double delx = 0.5 * (waferSize_ + waferSepar_);
0398   double dely = 2.0 * delx / sqrt3;
0399   double dy = 0.75 * dely;
0400   const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
0401 #ifdef EDM_ML_DEBUG
0402   int ium(0), ivm(0), kount(0);
0403   std::vector<int> ntype(3, 0);
0404   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: " << glog.ddname() << "  r " << delx << " R " << dely
0405                                 << " dy " << dy << " Shift " << xyoff.first << ":" << xyoff.second << " WaferSize "
0406                                 << (waferSize_ + waferSepar_) << " index " << firstWafer << ":" << (lastWafer - 1)
0407                                 << " Layer Center " << layercenter << ":" << layertype;
0408 #endif
0409   for (int k = firstWafer; k < lastWafer; ++k) {
0410     int u = HGCalWaferIndex::waferU(waferIndex_[k]);
0411     int v = HGCalWaferIndex::waferV(waferIndex_[k]);
0412 #ifdef EDM_ML_DEBUG
0413     int iu = std::abs(u);
0414     int iv = std::abs(v);
0415 #endif
0416     int nr = 2 * v;
0417     int nc = -2 * u + v;
0418     int type = HGCalProperty::waferThick(waferProperty_[k]);
0419     int part = HGCalProperty::waferPartial(waferProperty_[k]);
0420     int orien = HGCalProperty::waferOrient(waferProperty_[k]);
0421     int cassette = HGCalProperty::waferCassette(waferProperty_[k]);
0422     int place = HGCalCell::cellPlacementIndex(1, layertype, orien);
0423     auto cshift = cassette_.getShift(layer + 1, -1, cassette);
0424     double xpos = xyoff.first - cshift.first + nc * delx;
0425     double ypos = xyoff.second + cshift.second + nr * dy;
0426 #ifdef EDM_ML_DEBUG
0427     double xorig = xyoff.first + nc * delx;
0428     double yorig = xyoff.second + nr * dy;
0429     double angle = std::atan2(yorig, xorig);
0430     edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule::Wafer: layer " << layer + 1 << " cassette "
0431                                   << cassette << " Shift " << cshift.first << ":" << cshift.second << " Original "
0432                                   << xorig << ":" << yorig << ":" << convertRadToDeg(angle) << " Final " << xpos << ":"
0433                                   << ypos << " u|v " << u << ":" << v << " type|part|orient|place " << type << ":"
0434                                   << part << ":" << orien << ":" << place;
0435 #endif
0436     std::string wafer;
0437     int i(999);
0438     if (part == HGCalTypes::WaferFull) {
0439       i = type * facingTypes_ * orientationTypes_ + place - placeOffset_;
0440       wafer = waferFull_[i];
0441 #ifdef EDM_ML_DEBUG
0442       edm::LogVerbatim("HGCalGeom") << " layertype:type:part:orien:cassette:place:offsets:ind " << layertype << ":"
0443                                     << type << ":" << part << ":" << orien << ":" << cassette << ":" << place << ":"
0444                                     << placeOffset_ << ":" << facingTypes_ << ":" << orientationTypes_ << " wafer " << i
0445                                     << ":" << wafer;
0446 #endif
0447     } else {
0448       int partoffset = (part >= HGCalTypes::WaferHDTop) ? HGCalTypes::WaferPartHDOffset : HGCalTypes::WaferPartLDOffset;
0449       i = (part - partoffset) * facingTypes_ * orientationTypes_ +
0450           HGCalTypes::WaferTypeOffset[type] * facingTypes_ * orientationTypes_ + place - placeOffset_;
0451 #ifdef EDM_ML_DEBUG
0452       edm::LogVerbatim("HGCalGeom") << " layertype:type:part:orien:cassette:place:offsets:ind " << layertype << ":"
0453                                     << type << ":" << part << ":" << orien << ":" << cassette << ":" << place << ":"
0454                                     << partoffset << ":" << HGCalTypes::WaferTypeOffset[type] << ":" << i << ":"
0455                                     << waferPart_.size();
0456 #endif
0457       wafer = waferPart_[i];
0458     }
0459     int copy = HGCalTypes::packTypeUV(type, u, v);
0460 #ifdef EDM_ML_DEBUG
0461     edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedModule: Layer "
0462                                   << HGCalWaferIndex::waferLayer(waferIndex_[k]) << " Wafer " << wafer << " number "
0463                                   << copy << " type:part:orien:ind " << type << ":" << part << ":" << orien << ":" << i
0464                                   << " layer:u:v:indx " << (layer + firstLayer_) << ":" << u << ":" << v;
0465     if (iu > ium)
0466       ium = iu;
0467     if (iv > ivm)
0468       ivm = iv;
0469     kount++;
0470     if (copies_.count(copy) == 0)
0471       copies_.insert(copy);
0472 #endif
0473     DDTranslation tran(xpos, ypos, 0.0);
0474     DDRotation rotation;
0475     DDName name = DDName(DDSplit(wafer).first, DDSplit(wafer).second);
0476     cpv.position(name, glog.ddname(), copy, tran, rotation);
0477 #ifdef EDM_ML_DEBUG
0478     ++ntype[type];
0479     edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedModule: " << name << " number " << copy << " type "
0480                                   << layertype << ":" << type << " positioned in " << glog.ddname() << " at " << tran
0481                                   << " with no rotation";
0482 #endif
0483   }
0484 #ifdef EDM_ML_DEBUG
0485   edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedModule: Maximum # of u " << ium << " # of v " << ivm << " and "
0486                                 << kount << " wafers (" << ntype[0] << ":" << ntype[1] << ":" << ntype[2] << ") for "
0487                                 << glog.ddname();
0488 #endif
0489 }
0490 
0491 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalSiliconRotatedModule, "hgcal:DDHGCalSiliconRotatedModule");