|
|
Go to the documentation of this file.
29 #include <unordered_set>
59 static constexpr
double tol1_ = 0.01;
60 static constexpr
double tol2_ = 0.00001;
120 waferTypes_ = static_cast<int>(nArgs[
"WaferTypes"]);
121 facingTypes_ = static_cast<int>(nArgs[
"FacingTypes"]);
122 partialTypes_ = static_cast<int>(nArgs[
"PartialTypes"]);
123 orientationTypes_ = static_cast<int>(nArgs[
"OrientationTypes"]);
124 phiBinsScint_ = static_cast<int>(nArgs[
"NPhiBinScint"]);
126 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer::Number of types of wafers: " << waferTypes_
127 <<
" facings: " << facingTypes_ <<
" partials: " << partialTypes_
128 <<
" Orientations: " << orientationTypes_ <<
"; number of cells along phi "
131 firstLayer_ = (
int)(nArgs[
"FirstLayer"]);
132 absorbMode_ = (
int)(nArgs[
"AbsorberMode"]);
133 sensitiveMode_ = (
int)(nArgs[
"SensitiveMode"]);
135 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer::First Layer " << firstLayer_ <<
" and "
136 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
138 zMinBlock_ = nArgs[
"zMinBlock"];
139 waferSize_ = nArgs[
"waferSize"];
140 waferSepar_ = nArgs[
"SensorSeparation"];
141 sectors_ = (
int)(nArgs[
"Sectors"]);
142 alpha_ = (1._pi) / sectors_;
143 cosAlpha_ =
cos(alpha_);
145 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: zStart " << zMinBlock_ <<
" wafer width " << waferSize_
146 <<
" separations " << waferSepar_ <<
" sectors " << sectors_ <<
":"
149 slopeB_ = vArgs[
"SlopeBottom"];
150 zFrontB_ = vArgs[
"ZFrontBottom"];
151 rMinFront_ = vArgs[
"RMinFront"];
152 slopeT_ = vArgs[
"SlopeTop"];
153 zFrontT_ = vArgs[
"ZFrontTop"];
154 rMaxFront_ = vArgs[
"RMaxFront"];
156 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
157 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
158 <<
" Slope " << slopeB_[
i];
159 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
160 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
161 <<
" Slope " << slopeT_[
i];
163 waferFull_ = vsArgs[
"WaferNamesFull"];
164 waferPart_ = vsArgs[
"WaferNamesPartial"];
166 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: " << waferFull_.size() <<
" full and " << waferPart_.size()
167 <<
" partial modules\nDDHGCalMixLayer:Full Modules:";
168 unsigned int i1max = static_cast<unsigned int>(waferFull_.size());
169 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
170 std::ostringstream st1;
172 for (
unsigned int i =
i1;
i <
i2; ++
i)
173 st1 <<
" [" <<
i <<
"] " << waferFull_[
i];
177 i1max = static_cast<unsigned int>(waferPart_.size());
178 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
179 std::ostringstream st1;
181 for (
unsigned int i =
i1;
i <
i2; ++
i)
182 st1 <<
" [" <<
i <<
"] " << waferPart_[
i];
186 materials_ = vsArgs[
"MaterialNames"];
187 names_ = vsArgs[
"VolumeNames"];
188 thick_ = vArgs[
"Thickness"];
189 copyNumber_.resize(materials_.size(), 1);
191 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: " << materials_.size() <<
" types of volumes";
192 for (
unsigned int i = 0;
i < names_.size(); ++
i)
193 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
194 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
197 layerThick_ = vArgs[
"LayerThick"];
199 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
200 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
201 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" with " << layers_[
i]
205 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
206 layerCenter_ =
dbl_to_int(vArgs[
"LayerCenter"]);
208 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
211 if (firstLayer_ > 0) {
212 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
213 if (layerSense_[
i] > 0) {
214 int ii = layerType_[
i];
215 copyNumber_[
ii] = firstLayer_;
217 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with "
218 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
227 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
228 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
229 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
232 materialTop_ = vsArgs[
"TopMaterialNames"];
233 namesTop_ = vsArgs[
"TopVolumeNames"];
234 layerThickTop_ = vArgs[
"TopLayerThickness"];
235 layerTypeTop_ =
dbl_to_int(vArgs[
"TopLayerType"]);
236 copyNumberTop_.resize(materialTop_.size(), firstLayer_);
238 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: " << materialTop_.size() <<
" types of volumes in the top part";
239 for (
unsigned int i = 0;
i < materialTop_.size(); ++
i)
240 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesTop_[
i] <<
" of thickness " << layerThickTop_[
i]
241 <<
" filled with " << materialTop_[
i] <<
" first copy number " << copyNumberTop_[
i];
242 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeTop_.size() <<
" layers in the top part";
243 for (
unsigned int i = 0;
i < layerTypeTop_.size(); ++
i)
244 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeTop_[
i];
246 waferIndex_ =
dbl_to_int(vArgs[
"WaferIndex"]);
247 waferProperty_ =
dbl_to_int(vArgs[
"WaferProperties"]);
248 waferLayerStart_ =
dbl_to_int(vArgs[
"WaferLayerStart"]);
250 edm::LogVerbatim(
"HGCalGeom") <<
"waferProperties with " << waferIndex_.size() <<
" entries in "
251 << waferLayerStart_.size() <<
" layers";
252 for (
unsigned int k = 0;
k < waferLayerStart_.size(); ++
k)
254 for (
unsigned int k = 0;
k < waferIndex_.size(); ++
k)
263 tileRMin_ = vArgs[
"TileRMin"];
264 tileRMax_ = vArgs[
"TileRMax"];
265 tileIndex_ =
dbl_to_int(vArgs[
"TileLayerRings"]);
266 tilePhis_ =
dbl_to_int(vArgs[
"TilePhiRange"]);
267 tileLayerStart_ =
dbl_to_int(vArgs[
"TileLayerStart"]);
269 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer:: with " << tileRMin_.size() <<
" rings";
270 for (
unsigned int k = 0;
k < tileRMin_.size(); ++
k)
271 edm::LogVerbatim(
"HGCalGeom") <<
"Ring[" <<
k <<
"] " << tileRMin_[
k] <<
" : " << tileRMax_[
k];
272 edm::LogVerbatim(
"HGCalGeom") <<
"TileProperties with " << tileIndex_.size() <<
" entries in "
273 << tileLayerStart_.size() <<
" layers";
274 for (
unsigned int k = 0;
k < tileLayerStart_.size(); ++
k)
276 for (
unsigned int k = 0;
k < tileIndex_.size(); ++
k)
286 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: NameSpace " << nameSpace_;
301 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: " << copies_.size() <<
" different wafer copy numbers";
303 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
307 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalMixLayer construction...";
315 double zi(zMinBlock_);
317 for (
unsigned int i = 0;
i < layers_.size();
i++) {
318 double zo = zi + layerThick_[
i];
320 int laymax = laymin + layers_[
i];
323 for (
int ly = laymin; ly < laymax; ++ly) {
324 int ii = layerType_[ly];
325 int copy = copyNumber_[
ii];
326 double hthick = 0.5 * thick_[
ii];
329 thickTot += thick_[
ii];
333 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " << routF
334 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick_[
i];
339 if (layerSense_[ly] < 1) {
340 std::vector<double> pgonZ, pgonRin, pgonRout;
355 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
357 if (layerSense_[ly] == 0 || absorbMode_ == 0)
358 pgonRout[isec] = rmax;
360 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
366 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: " << solid.
name() <<
" polyhedra of " << sectors_
368 <<
convertRadToDeg(-alpha_ + 2._pi) <<
" with " << pgonZ.size() <<
" sections";
369 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
370 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
379 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: " << solid.
name() <<
" Tubs made of " << matName
380 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
381 <<
", " << hthick <<
", 0.0, 360.0 and positioned in: " << glog.
name()
382 <<
" number " <<
copy;
384 positionMix(glog,
name,
copy, thick_[
ii], matter, layerSense_[ly], cpv);
392 << module.
name() <<
" at " <<
r1 <<
" with no rotation";
399 if (
std::abs(thickTot - layerThick_[
i]) >= tol2_) {
400 if (thickTot > layerThick_[
i]) {
401 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
402 <<
": thickness of all its components **** ERROR ****";
404 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with "
405 << thickTot <<
" of the components";
421 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
422 int ii = layerTypeTop_[ly];
423 copyNumberTop_[
ii] = copyM;
425 double hthick = 0.5 * thick;
426 double dphi = (2._pi) / phiBinsScint_;
427 double thickTot(0), zpos(-hthick);
428 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
429 int ii = layerTypeTop_[ly];
430 int copy = copyNumberTop_[
ii];
432 double hthickl = 0.5 * layerThickTop_[
ii];
433 thickTot += layerThickTop_[
ii];
438 int firstTile = tileLayerStart_[
layer];
439 int lastTile = ((
layer + 1 < static_cast<int>(tileLayerStart_.size())) ? tileLayerStart_[
layer + 1]
440 : static_cast<int>(tileIndex_.size()));
442 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: Layer " << ly <<
":" <<
ii <<
" Copy " <<
copy <<
" Tiles "
443 << firstTile <<
":" << lastTile;
445 for (
int ti = firstTile; ti < lastTile; ++ti) {
450 double phi1 = dphi * (fimin - 1);
451 double phi2 = dphi * (fimax - fimin + 1);
456 <<
r2 <<
" Thick " << (2.0 * hthickl) <<
" phi " << fimin <<
":" << fimax <<
":"
465 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: " << glog1.
name() <<
" Tubs made of " << matName
466 <<
" of dimensions " <<
r1 <<
", " <<
r2 <<
", " << hthickl <<
", "
473 << glog.
name() <<
" at " << tran <<
" with no rotation";
476 ++copyNumberTop_[
ii];
479 if (
std::abs(thickTot - thick) >= tol2_) {
480 if (thickTot > thick) {
481 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
482 <<
": thickness of all its components in the top part **** ERROR ****";
484 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
485 <<
" of the components in top part";
490 int layer = (copyM - firstLayer_);
491 static const double sqrt3 =
std::sqrt(3.0);
492 int layercenter = layerCenter_[
layer];
493 int firstWafer = waferLayerStart_[
layer];
494 int lastWafer = ((
layer + 1 < static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[
layer + 1]
495 : static_cast<int>(waferIndex_.size()));
496 double r = 0.5 * (waferSize_ + waferSepar_);
497 double R = 2.0 *
r / sqrt3;
498 double dy = 0.75 *
R;
499 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
501 int ium(0), ivm(0), kount(0);
502 std::vector<int> ntype(3, 0);
504 <<
" Shift " << xyoff.first <<
":" << xyoff.second <<
" WaferSize "
505 << (waferSize_ + waferSepar_) <<
" index " << firstWafer <<
":" << (lastWafer - 1);
507 for (
int k = firstWafer;
k < lastWafer; ++
k) {
516 double xpos = xyoff.first + nc *
r;
517 double ypos = xyoff.second +
nr *
dy;
524 i = (layerType - 1) * waferTypes_ +
type;
525 wafer = waferFull_[
i];
527 i = (
part - 1) * waferTypes_ * facingTypes_ * orientationTypes_ +
528 (layerType - 1) * waferTypes_ * orientationTypes_ +
type * orientationTypes_ + orien;
531 <<
":" << orien <<
":" <<
i <<
":" << waferPart_.size();
533 wafer = waferPart_[
i];
538 <<
" Wafer " << wafer <<
" number " <<
copy <<
" type :part:orien:ind " <<
type <<
":"
539 <<
part <<
":" << orien <<
":" <<
i <<
" layer:u:v " << (
layer + firstLayer_) <<
":"
546 if (copies_.count(
copy) == 0)
547 copies_.insert(
copy);
555 <<
type <<
" positioned in " << glog.
ddname() <<
" at " << tran
556 <<
" with no rotation";
560 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalMixLayer: Maximum # of u " << ium <<
" # of v " << ivm <<
" and " << kount
561 <<
" wafers (" << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
") for "
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
DDName is used to identify DDD entities uniquely.
std::vector< double > rMinFront_
constexpr NumType convertRadToDeg(NumType radians)
std::vector< std::string > materials_
std::vector< double > layerThick_
int32_t waferU(const int32_t index)
int32_t waferOrient(const int32_t property)
std::vector< double > zFrontB_
std::vector< int > layerType_
U second(std::pair< T, U > const &p)
std::vector< int > waferProperty_
std::vector< int > tilePhis_
std::vector< int > layerTypeTop_
void execute(DDCompactView &cpv) override
Log< level::Warning, false > LogWarning
std::vector< std::string > names_
std::vector< std::string > waferFull_
std::vector< std::string > materialTop_
DDMaterial is used to define and access material information.
std::vector< int > copyNumberTop_
Cos< T >::type cos(const T &t)
std::vector< int > waferLayerStart_
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)
Compact representation of the geometrical detector hierarchy.
std::vector< std::string > namesTop_
int32_t waferV(const int32_t index)
HGCalGeomTools geomTools_
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
std::vector< int > layers_
std::vector< double > rMaxFront_
#define DEFINE_EDM_PLUGIN(factory, type, name)
static int32_t packTypeUV(int type, int u, int v)
std::vector< int > layerCenter_
constexpr std::array< uint8_t, layerIndexSize > layer
void positionMix(const DDLogicalPart &glog, const std::string &nameM, int copyM, double thick, const DDMaterial &matter, int layerType, DDCompactView &cpv)
std::vector< double > layerThickTop_
std::tuple< int32_t, int32_t, int32_t > tileUnpack(int32_t index)
std::vector< int > tileIndex_
std::vector< double > thick_
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
std::vector< double > slopeT_
int32_t waferThick(const int32_t property)
std::vector< int > tileLayerStart_
std::vector< std::string > waferPart_
Log< level::Error, false > LogError
std::vector< int > copyNumber_
int32_t waferPartial(const int32_t property)
std::vector< double > slopeB_
std::vector< double > zFrontT_
int32_t waferLayer(const int32_t index)
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)
Log< level::Info, true > LogVerbatim
static std::string & ns()
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
A DDSolid represents the shape of a part.
Represents a uniquely identifyable rotation matrix.
std::vector< int > waferIndex_
static AlgebraicMatrix initialize()
Abs< T >::type abs(const T &t)
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 > layerSense_
std::unordered_set< int > copies_
std::vector< double > tileRMax_
std::vector< double > tileRMin_
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string ©no, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)