31 #include <unordered_set> 61 static constexpr
double tol1_ = 0.01;
62 static constexpr
double tol2_ = 0.00001;
115 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: Creating an instance";
124 waferTypes_ =
static_cast<int>(nArgs[
"WaferTypes"]);
125 facingTypes_ =
static_cast<int>(nArgs[
"FacingTypes"]);
126 orientationTypes_ =
static_cast<int>(nArgs[
"OrientationTypes"]);
127 placeOffset_ =
static_cast<int>(nArgs[
"PlaceOffset"]);
128 phiBinsScint_ =
static_cast<int>(nArgs[
"NPhiBinScint"]);
130 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer::Number of types of wafers: " << waferTypes_
131 <<
" facings: " << facingTypes_ <<
" Orientations: " << orientationTypes_
132 <<
" PlaceOffset: " << placeOffset_ <<
"; number of cells along phi " << phiBinsScint_;
134 firstLayer_ = (
int)(nArgs[
"FirstLayer"]);
135 absorbMode_ = (
int)(nArgs[
"AbsorberMode"]);
136 sensitiveMode_ = (
int)(nArgs[
"SensitiveMode"]);
138 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer::First Layer " << firstLayer_ <<
" and " 139 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
141 zMinBlock_ = nArgs[
"zMinBlock"];
142 waferSize_ = nArgs[
"waferSize"];
143 waferSepar_ = nArgs[
"SensorSeparation"];
144 sectors_ =
static_cast<int>(nArgs[
"Sectors"]);
145 cassettes_ =
static_cast<int>(nArgs[
"Cassettes"]);
146 alpha_ = (1._pi) / sectors_;
147 cosAlpha_ =
cos(alpha_);
149 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: zStart " << zMinBlock_ <<
" wafer width " << waferSize_
150 <<
" separations " << waferSepar_ <<
" sectors " << sectors_ <<
":" 151 <<
convertRadToDeg(alpha_) <<
":" << cosAlpha_ <<
" with " << cassettes_
154 slopeB_ = vArgs[
"SlopeBottom"];
155 zFrontB_ = vArgs[
"ZFrontBottom"];
156 rMinFront_ = vArgs[
"RMinFront"];
157 slopeT_ = vArgs[
"SlopeTop"];
158 zFrontT_ = vArgs[
"ZFrontTop"];
159 rMaxFront_ = vArgs[
"RMaxFront"];
161 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
162 edm::LogVerbatim(
"HGCalGeom") <<
"Bottom Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
163 <<
" Slope " << slopeB_[
i];
164 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
165 edm::LogVerbatim(
"HGCalGeom") <<
"Top Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
166 <<
" Slope " << slopeT_[
i];
168 waferFull_ = vsArgs[
"WaferNamesFull"];
169 waferPart_ = vsArgs[
"WaferNamesPartial"];
171 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << waferFull_.size() <<
" full and " << waferPart_.size()
172 <<
" partial modules\nDDHGCalMixRotatedLayer:Full Modules:";
173 unsigned int i1max =
static_cast<unsigned int>(waferFull_.size());
174 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
175 std::ostringstream st1;
177 for (
unsigned int i =
i1;
i <
i2; ++
i)
178 st1 <<
" [" <<
i <<
"] " << waferFull_[
i];
181 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: Partial Modules:";
182 i1max =
static_cast<unsigned int>(waferPart_.size());
183 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
184 std::ostringstream st1;
186 for (
unsigned int i =
i1;
i <
i2; ++
i)
187 st1 <<
" [" <<
i <<
"] " << waferPart_[
i];
191 materials_ = vsArgs[
"MaterialNames"];
192 names_ = vsArgs[
"VolumeNames"];
193 thick_ = vArgs[
"Thickness"];
194 copyNumber_.resize(materials_.size(), 1);
196 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << materials_.size() <<
" types of volumes";
197 for (
unsigned int i = 0;
i < names_.size(); ++
i)
198 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
199 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
202 layerThick_ = vArgs[
"LayerThick"];
204 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
205 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
206 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" with " << layers_[
i]
210 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
211 layerOrient_ =
dbl_to_int(vArgs[
"LayerTypes"]);
212 for (
unsigned int k = 0;
k < layerOrient_.size(); ++
k)
215 for (
unsigned int i = 0;
i < layerOrient_.size(); ++
i)
218 if (firstLayer_ > 0) {
219 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
220 if (layerSense_[
i] > 0) {
221 int ii = layerType_[
i];
222 copyNumber_[
ii] = firstLayer_;
224 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with " 225 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
234 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
235 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
236 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class " 239 materialTop_ = vsArgs[
"TopMaterialNames"];
240 namesTop_ = vsArgs[
"TopVolumeNames"];
241 layerThickTop_ = vArgs[
"TopLayerThickness"];
242 layerTypeTop_ =
dbl_to_int(vArgs[
"TopLayerType"]);
243 copyNumberTop_.resize(materialTop_.size(), firstLayer_);
245 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << materialTop_.size()
246 <<
" types of volumes in the top part";
247 for (
unsigned int i = 0;
i < materialTop_.size(); ++
i)
248 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesTop_[
i] <<
" of thickness " << layerThickTop_[
i]
249 <<
" filled with " << materialTop_[
i] <<
" first copy number " << copyNumberTop_[
i];
250 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeTop_.size() <<
" layers in the top part";
251 for (
unsigned int i = 0;
i < layerTypeTop_.size(); ++
i)
252 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeTop_[
i];
254 waferIndex_ =
dbl_to_int(vArgs[
"WaferIndex"]);
255 waferProperty_ =
dbl_to_int(vArgs[
"WaferProperties"]);
256 waferLayerStart_ =
dbl_to_int(vArgs[
"WaferLayerStart"]);
257 cassetteShift_ = vArgs[
"CassetteShift"];
259 edm::LogVerbatim(
"HGCalGeom") <<
"waferProperties with " << waferIndex_.size() <<
" entries in " 260 << waferLayerStart_.size() <<
" layers";
261 for (
unsigned int k = 0;
k < waferLayerStart_.size(); ++
k)
263 for (
unsigned int k = 0;
k < waferIndex_.size(); ++
k)
271 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << cassetteShift_.size()
272 <<
" elements for cassette shifts";
273 unsigned int j1max = cassetteShift_.size();
274 for (
unsigned int j1 = 0; j1 < j1max; j1 += 6) {
275 std::ostringstream st1;
276 unsigned int j2 =
std::min((j1 + 6), j1max);
277 for (
unsigned int j = j1;
j < j2; ++
j)
278 st1 <<
" [" <<
j <<
"] " << std::setw(9) << cassetteShift_[
j];
282 tileRMin_ = vArgs[
"TileRMin"];
283 tileRMax_ = vArgs[
"TileRMax"];
284 tileIndex_ =
dbl_to_int(vArgs[
"TileLayerRings"]);
285 tilePhis_ =
dbl_to_int(vArgs[
"TilePhiRange"]);
286 tileLayerStart_ =
dbl_to_int(vArgs[
"TileLayerStart"]);
288 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer:: with " << tileRMin_.size() <<
" rings";
289 for (
unsigned int k = 0;
k < tileRMin_.size(); ++
k)
290 edm::LogVerbatim(
"HGCalGeom") <<
"Ring[" <<
k <<
"] " << tileRMin_[
k] <<
" : " << tileRMax_[
k];
291 edm::LogVerbatim(
"HGCalGeom") <<
"TileProperties with " << tileIndex_.size() <<
" entries in " 292 << tileLayerStart_.size() <<
" layers";
293 for (
unsigned int k = 0;
k < tileLayerStart_.size(); ++
k)
295 for (
unsigned int k = 0;
k < tileIndex_.size(); ++
k)
305 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: NameSpace " << nameSpace_ <<
":";
307 cassette_.setParameter(cassettes_, cassetteShift_);
316 edm::LogVerbatim(
"HGCalGeom") <<
"==>> Constructing DDHGCalMixRotatedLayer...";
321 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << copies_.size() <<
" different wafer copy numbers";
323 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
327 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalMixRotatedLayer construction...";
332 double zi(zMinBlock_);
334 for (
unsigned int i = 0;
i < layers_.size();
i++) {
335 double zo = zi + layerThick_[
i];
337 int laymax = laymin + layers_[
i];
340 for (
int ly = laymin; ly < laymax; ++ly) {
341 int ii = layerType_[ly];
342 int copy = copyNumber_[
ii];
343 double hthick = 0.5 * thick_[
ii];
346 thickTot += thick_[
ii];
350 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " 351 << routF <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " 357 if (layerSense_[ly] < 1) {
358 std::vector<double> pgonZ, pgonRin, pgonRout;
373 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
375 if (layerSense_[ly] == 0 || absorbMode_ == 0)
376 pgonRout[isec] = rmax;
378 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
384 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << solid.
name() <<
" polyhedra of " << sectors_
386 <<
convertRadToDeg(-alpha_ + 2._pi) <<
" with " << pgonZ.size() <<
" sections";
387 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
388 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
397 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << solid.
name() <<
" Tubs made of " << matName
398 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
399 <<
", " << hthick <<
", 0.0, 360.0 and positioned in: " << glog.
name()
400 <<
" number " <<
copy;
402 positionMix(glog,
name,
copy, thick_[
ii], matter, cpv);
410 <<
" positioned in " <<
module.name() <<
" at " <<
r1 <<
" with no rotation";
417 if (
std::abs(thickTot - layerThick_[
i]) >= tol2_) {
418 if (thickTot > layerThick_[
i]) {
419 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
420 <<
": thickness of all its components **** ERROR ****";
422 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with " 423 << thickTot <<
" of the components";
438 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
439 int ii = layerTypeTop_[ly];
440 copyNumberTop_[
ii] = copyM;
442 double hthick = 0.5 * thick;
443 double dphi = (2._pi) / phiBinsScint_;
444 double thickTot(0), zpos(-hthick);
445 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
446 int ii = layerTypeTop_[ly];
447 int copy = copyNumberTop_[
ii];
449 double hthickl = 0.5 * layerThickTop_[
ii];
450 thickTot += layerThickTop_[
ii];
455 int firstTile = tileLayerStart_[
layer];
456 int lastTile = ((
layer + 1 <
static_cast<int>(tileLayerStart_.size())) ? tileLayerStart_[
layer + 1]
457 :
static_cast<int>(tileIndex_.size()));
460 <<
" Tiles " << firstTile <<
":" << lastTile;
462 for (
int ti = firstTile; ti < lastTile; ++ti) {
468 double phi1 = dphi * (fimin - 1);
469 double phi2 = dphi * (fimax - fimin + 1);
470 auto cshift = cassette_.getShift(
layer + 1, 1, cassette);
475 <<
r2 <<
" Thick " << (2.0 * hthickl) <<
" phi " << fimin <<
":" << fimax <<
":" 477 <<
" Shift " << cshift.first <<
":" << cshift.second;
484 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << glog1.
name() <<
" Tubs made of " << matName
485 <<
" of dimensions " <<
r1 <<
", " <<
r2 <<
", " << hthickl <<
", " 492 <<
" in " << glog.
name() <<
" at " << tran <<
" with no rotation";
495 ++copyNumberTop_[
ii];
498 if (
std::abs(thickTot - thick) >= tol2_) {
499 if (thickTot > thick) {
500 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
501 <<
": thickness of all its components in the top part **** ERROR ****";
503 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
504 <<
" of the components in top part";
509 int layer = (copyM - firstLayer_);
510 static const double sqrt3 =
std::sqrt(3.0);
511 int layercenter = layerOrient_[
layer];
513 int firstWafer = waferLayerStart_[
layer];
514 int lastWafer = ((
layer + 1 <
static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[
layer + 1]
515 :
static_cast<int>(waferIndex_.size()));
516 double delx = 0.5 * (waferSize_ + waferSepar_);
517 double dely = 2.0 * delx / sqrt3;
518 double dy = 0.75 * dely;
519 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
521 int ium(0), ivm(0), kount(0);
522 std::vector<int> ntype(3, 0);
523 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: " << glog.
ddname() <<
" r " << delx <<
" R " << dely
524 <<
" dy " <<
dy <<
" Shift " << xyoff.first <<
":" << xyoff.second <<
" WaferSize " 525 << (waferSize_ + waferSepar_) <<
" index " << firstWafer <<
":" << (lastWafer - 1);
527 for (
int k = firstWafer;
k < lastWafer; ++
k) {
542 edm::LogVerbatim(
"HGCalGeom") <<
" index:Property:layertype:type:part:orien:cassette:place:offsets:ind " <<
k <<
":" 543 << waferProperty_[
k] <<
":" << layertype <<
":" <<
type <<
":" <<
part <<
":" << orien
544 <<
":" << cassette <<
":" << place;
546 auto cshift = cassette_.getShift(
layer + 1, 1, cassette);
547 double xpos = xyoff.first + cshift.first + nc * delx;
548 double ypos = xyoff.second + cshift.second +
nr *
dy;
552 i =
type * facingTypes_ * orientationTypes_ + place - placeOffset_;
554 edm::LogVerbatim(
"HGCalGeom") <<
" FullWafer type:place:ind " <<
type <<
":" << place <<
":" <<
i <<
":" 555 << waferFull_.size();
557 wafer = waferFull_[
i];
560 i = (
part - partoffset) * facingTypes_ * orientationTypes_ +
563 edm::LogVerbatim(
"HGCalGeom") <<
" layertype:type:part:orien:cassette:place:offsets:ind " << layertype <<
":" 564 <<
type <<
":" <<
part <<
":" << orien <<
":" << cassette <<
":" << place <<
":" 566 << waferPart_.size();
568 wafer = waferPart_[
i];
573 <<
" Wafer " << wafer <<
" number " <<
copy <<
" type :part:orien:ind " <<
type <<
":" 574 <<
part <<
":" << orien <<
":" <<
i <<
" layer:u:v " << (
layer + firstLayer_) <<
":" 581 if (copies_.count(
copy) == 0)
582 copies_.insert(
copy);
590 <<
":" <<
type <<
" positioned in " << glog.
ddname() <<
" at " << tran
591 <<
" with no rotation";
595 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixRotatedLayer: Maximum # of u " << ium <<
" # of v " << ivm <<
" and " 596 << kount <<
" wafers (" << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
") for "
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
static int32_t cellPlacementIndex(int32_t iz, int32_t frontBack, int32_t orient)
static constexpr int32_t WaferPartLDOffset
std::vector< double > slopeT_
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string ©no, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
static constexpr int32_t WaferTypeOffset[3]
HGCalGeomTools geomTools_
std::vector< double > slopeB_
DDMaterial is used to define and access material information.
int32_t waferU(const int32_t index)
std::vector< double > cassetteShift_
int32_t waferLayer(const int32_t index)
constexpr NumType convertRadToDeg(NumType radians)
DDName is used to identify DDD entities uniquely.
std::string to_string(const V &value)
std::vector< int > copyNumberTop_
std::vector< double > zFrontB_
static std::string & ns()
std::vector< double > tileRMin_
std::vector< double > thick_
std::vector< std::string > materials_
std::vector< double > rMaxFront_
Log< level::Error, false > LogError
std::vector< int > layers_
std::vector< std::string > waferFull_
std::vector< int > waferLayerStart_
Compact representation of the geometrical detector hierarchy.
int32_t waferOrient(const int32_t property)
std::vector< int > waferIndex_
A DDSolid represents the shape of a part.
constexpr std::array< uint8_t, layerIndexSize > layer
Represents a uniquely identifyable rotation matrix.
U second(std::pair< T, U > const &p)
int32_t waferCassette(const int32_t property)
static constexpr int32_t WaferFull
std::vector< double > layerThick_
std::vector< int > copyNumber_
std::vector< int > tilePhis_
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
void constructLayers(const cms::DDNamespace &ns, const std::vector< std::string > &wafers, const std::vector< std::string > &covers, const std::vector< int > &layerType, const std::vector< int > &layerSense, const std::vector< int > &maxModule, const std::vector< std::string > &names, const std::vector< std::string > &materials, std::vector< int > ©Number, const std::vector< double > &layerThick, const double &absorbW, const double &absorbH, const double &waferTot, const double &rMax, const double &rMaxFine, std::unordered_set< int > &copies, int firstLayer, int lastLayer, double zFront, double totalWidth, bool ignoreCenter, dd4hep::Volume &module)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
std::vector< int > layerSense_
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
int32_t waferThick(const int32_t property)
void execute(DDCompactView &cpv) override
std::vector< double > tileRMax_
std::vector< int > layerTypeTop_
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
std::vector< double > layerThickTop_
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
std::vector< int > waferProperty_
std::tuple< int32_t, int32_t, int32_t > tileUnpack(int32_t index)
static constexpr int32_t WaferPartHDOffset
void positionMix(const DDLogicalPart &glog, const std::string &nameM, int copyM, double thick, const DDMaterial &matter, DDCompactView &cpv)
std::vector< std::string > waferPart_
std::vector< double > rMinFront_
std::vector< double > zFrontT_
int32_t waferPartial(const int32_t property)
std::vector< std::string > materialTop_
int32_t waferV(const int32_t index)
static int32_t packTypeUV(int type, int u, int v)
static constexpr int32_t WaferHDTop
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::string > namesTop_
std::vector< std::string > names_
Log< level::Warning, false > LogWarning
static int32_t layerType(int type)
std::vector< int > layerType_
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
static DDSolid polyhedra(const DDName &name, int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polyhedra (refere to Geant3 or Geant4 documentation)
static int32_t layerFrontBack(int32_t layerOrient)
std::vector< int > layerOrient_
std::vector< int > tileLayerStart_
std::unordered_set< int > copies_
std::vector< int > tileIndex_
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override