28 #include <unordered_set> 57 void positionSensitive(
63 static constexpr
double tol1_ = 0.01;
64 static constexpr
double tol2_ = 0.00001;
120 wafers_ = vsArgs[
"WaferNames"];
122 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << wafers_.size() <<
" wafers";
123 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
126 materials_ = vsArgs[
"MaterialNames"];
127 names_ = vsArgs[
"VolumeNames"];
128 thick_ = vArgs[
"Thickness"];
129 copyNumber_.resize(materials_.size(), 1);
131 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << materials_.size() <<
" types of volumes";
132 for (
unsigned int i = 0;
i < names_.size(); ++
i)
133 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
134 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
137 layerThick_ = vArgs[
"LayerThick"];
138 rMixLayer_ = vArgs[
"LayerRmix"];
140 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
141 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
142 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" Rmid " << rMixLayer_[
i]
143 <<
" with " << layers_[
i] <<
" layers";
146 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
147 firstLayer_ = (
int)(nArgs[
"FirstLayer"]);
148 absorbMode_ = (
int)(nArgs[
"AbsorberMode"]);
149 sensitiveMode_ = (
int)(nArgs[
"SensitiveMode"]);
152 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
154 layerCenter_ =
dbl_to_int(vArgs[
"LayerCenter"]);
156 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
159 if (firstLayer_ > 0) {
160 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
161 if (layerSense_[
i] > 0) {
162 int ii = layerType_[
i];
163 copyNumber_[
ii] = firstLayer_;
165 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with " 166 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
175 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
176 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
177 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class " 180 materialsTop_ = vsArgs[
"TopMaterialNames"];
181 namesTop_ = vsArgs[
"TopVolumeNames"];
182 layerThickTop_ = vArgs[
"TopLayerThickness"];
183 layerTypeTop_ =
dbl_to_int(vArgs[
"TopLayerType"]);
184 copyNumberTop_.resize(materialsTop_.size(), 1);
186 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << materialsTop_.size() <<
" types of volumes in the top part";
187 for (
unsigned int i = 0;
i < materialsTop_.size(); ++
i)
188 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesTop_[
i] <<
" of thickness " << layerThickTop_[
i]
189 <<
" filled with " << materialsTop_[
i] <<
" first copy number " << copyNumberTop_[
i];
190 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeTop_.size() <<
" layers in the top part";
191 for (
unsigned int i = 0;
i < layerTypeTop_.size(); ++
i)
192 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeTop_[
i];
194 materialsBot_ = vsArgs[
"BottomMaterialNames"];
195 namesBot_ = vsArgs[
"BottomVolumeNames"];
196 layerTypeBot_ =
dbl_to_int(vArgs[
"BottomLayerType"]);
197 layerSenseBot_ =
dbl_to_int(vArgs[
"BottomLayerSense"]);
198 layerThickBot_ = vArgs[
"BottomLayerThickness"];
199 copyNumberBot_.resize(materialsBot_.size(), 1);
201 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << materialsBot_.size()
202 <<
" types of volumes in the bottom part";
203 for (
unsigned int i = 0;
i < materialsBot_.size(); ++
i)
204 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesBot_[
i] <<
" of thickness " << layerThickBot_[
i]
205 <<
" filled with " << materialsBot_[
i] <<
" first copy number " << copyNumberBot_[
i];
206 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeBot_.size() <<
" layers in the bottom part";
207 for (
unsigned int i = 0;
i < layerTypeBot_.size(); ++
i)
208 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeBot_[
i]
209 <<
" sensitive class " << layerSenseBot_[
i];
211 zMinBlock_ = nArgs[
"zMinBlock"];
212 waferSize_ = nArgs[
"waferSize"];
213 waferSepar_ = nArgs[
"SensorSeparation"];
214 sectors_ = (
int)(nArgs[
"Sectors"]);
215 alpha_ = (1._pi) / sectors_;
216 cosAlpha_ =
cos(alpha_);
218 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: zStart " << zMinBlock_ <<
" wafer width " << waferSize_
219 <<
" separations " << waferSepar_ <<
" sectors " << sectors_ <<
":" 222 waferIndex_ =
dbl_to_int(vArgs[
"WaferIndex"]);
223 waferProperty_ =
dbl_to_int(vArgs[
"WaferProperties"]);
225 edm::LogVerbatim(
"HGCalGeom") <<
"waferProperties with " << waferIndex_.size() <<
" entries";
226 for (
unsigned int k = 0;
k < waferIndex_.size(); ++
k)
235 slopeB_ = vArgs[
"SlopeBottom"];
236 zFrontB_ = vArgs[
"ZFrontBottom"];
237 rMinFront_ = vArgs[
"RMinFront"];
238 slopeT_ = vArgs[
"SlopeTop"];
239 zFrontT_ = vArgs[
"ZFrontTop"];
240 rMaxFront_ = vArgs[
"RMaxFront"];
242 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
243 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
244 <<
" Slope " << slopeB_[
i];
245 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
246 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
247 <<
" Slope " << slopeT_[
i];
251 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: NameSpace " << nameSpace_ <<
":";
266 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << copies_.size() <<
" different wafer copy numbers";
268 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
272 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalHEFileAlgo construction...";
277 double zi(zMinBlock_);
279 for (
unsigned int i = 0;
i < layers_.size();
i++) {
280 double zo = zi + layerThick_[
i];
282 int laymax = laymin + layers_[
i];
285 for (
int ly = laymin; ly < laymax; ++ly) {
286 int ii = layerType_[ly];
287 int copy = copyNumber_[
ii];
288 double hthick = 0.5 * thick_[
ii];
291 thickTot += thick_[
ii];
295 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " 296 << routF <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " 302 if (layerSense_[ly] < 1) {
303 std::vector<double> pgonZ, pgonRin, pgonRout;
318 for (
unsigned int isec = 0;
isec < pgonZ.size(); ++
isec) {
320 if (layerSense_[ly] == 0 || absorbMode_ == 0)
321 pgonRout[
isec] = rmax;
323 pgonRout[
isec] = pgonRout[
isec] * cosAlpha_ - tol1_;
329 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << solid.
name() <<
" polyhedra of " << sectors_
331 <<
convertRadToDeg(-alpha_ + 2._pi) <<
" with " << pgonZ.size() <<
" sections";
332 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
333 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
342 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << solid.
name() <<
" Tubs made of " << matName
343 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
344 <<
", " << hthick <<
", 0.0, 360.0 and positioned in: " << glog.
name()
345 <<
" number " <<
copy;
347 positionMix(glog,
name,
copy, thick_[
ii], matter, rins, rMixLayer_[
i], routs,
zz, cpv);
355 <<
module.name() <<
" at " << r1 <<
" with no rotation";
362 if (
std::abs(thickTot - layerThick_[
i]) >= tol2_) {
363 if (thickTot > layerThick_[
i]) {
364 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
365 <<
": thickness of all its components **** ERROR ****";
367 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with " 368 << thickTot <<
" of the components";
387 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
388 int ii = layerTypeTop_[ly];
389 copyNumberTop_[
ii] = copyM;
391 for (
unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
392 int ii = layerTypeBot_[ly];
393 copyNumberBot_[
ii] = copyM;
395 double hthick = 0.5 * thick;
402 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthick <<
", 0.0, 360.0";
407 <<
" at " << tran <<
" with no rotation";
409 double thickTot(0), zpos(-hthick);
410 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
411 int ii = layerTypeTop_[ly];
412 int copy = copyNumberTop_[
ii];
413 double hthickl = 0.5 * layerThickTop_[
ii];
414 thickTot += layerThickTop_[
ii];
417 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rmid <<
":" << rout
418 <<
" Thick " << layerThickTop_[
ii];
429 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << solid.
name() <<
" Tubs made of " << matName
430 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthickl <<
", 0.0, 360.0";
437 << glog1.
name() <<
" at " << r1 <<
" with no rotation";
439 ++copyNumberTop_[
ii];
442 if (
std::abs(thickTot - thick) >= tol2_) {
443 if (thickTot > thick) {
444 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
445 <<
": thickness of all its components in the top part **** ERROR ****";
447 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
448 <<
" of the components in top part";
453 name = nameM +
"Bottom";
458 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthick <<
", 0.0, 360.0";
463 <<
" at " << tran <<
" with no rotation";
467 for (
unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
468 int ii = layerTypeBot_[ly];
469 int copy = copyNumberBot_[
ii];
470 double hthickl = 0.5 * layerThickBot_[
ii];
471 thickTot += layerThickBot_[
ii];
474 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rin <<
":" << rmid
475 <<
" Thick " << layerThickBot_[
ii];
486 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << solid.
name() <<
" Tubs made of " << matName
487 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthickl <<
", 0.0, 360.0";
494 << glog1.
name() <<
" at " << r1 <<
" with no rotation";
496 if (layerSenseBot_[ly] != 0) {
499 << (
copy - firstLayer_) <<
":" << layerCenter_[
copy - firstLayer_];
501 positionSensitive(glog2, rin, rmid,
zz + zpos, layerSenseBot_[ly], (
copy - firstLayer_), cpv);
504 ++copyNumberBot_[
ii];
506 if (
std::abs(thickTot - thick) >= tol2_) {
507 if (thickTot > thick) {
508 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
509 <<
": thickness of all its components in the top part **** ERROR ****";
511 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
512 <<
" of the components in top part";
519 static const double sqrt3 =
std::sqrt(3.0);
520 int layercenter = layerCenter_[layer];
521 double r = 0.5 * (waferSize_ + waferSepar_);
522 double R = 2.0 * r / sqrt3;
523 double dy = 0.75 *
R;
524 int N = (
int)(0.5 * rout / r) + 2;
525 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
527 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0),
ntot(0), nin(0);
528 std::vector<int> ntype(6, 0);
529 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << glog.
ddname() <<
" rin:rout " << rin <<
":" << rout
530 <<
" zpos " << zpos <<
" N " <<
N <<
" for maximum u, v Offset; Shift " << xyoff.first
531 <<
":" << xyoff.second <<
" WaferSize " << (waferSize_ + waferSepar_);
533 for (
int u = -
N; u <=
N; ++u) {
534 for (
int v = -
N;
v <=
N; ++
v) {
541 double xpos = xyoff.first + nc * r;
542 double ypos = xyoff.second +
nr *
dy;
555 <<
type <<
" layer:u:v:indx " << (layer + firstLayer_) <<
":" << u <<
":" <<
v 562 if (copies_.count(
copy) == 0)
563 copies_.insert(
copy);
580 <<
":" <<
type <<
" positioned in " << glog.
ddname() <<
" at " << tran
581 <<
" with no rotation";
588 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
589 <<
":" << ivmAll <<
" and " << nin <<
":" << kount <<
":" <<
ntot <<
" wafers (" 590 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":" << ntype[4]
591 <<
":" << ntype[5] <<
") for " << glog.
ddname() <<
" R " << rin <<
":" << rout;
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
std::vector< int > layerSense_
std::vector< int > copyNumber_
std::vector< double > rMaxFront_
static int getType(int index, const HGCalParameters::waferInfo_map &wafers)
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string ©no, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDMaterial is used to define and access material information.
int32_t waferU(const int32_t index)
int32_t waferLayer(const int32_t index)
constexpr NumType convertRadToDeg(NumType radians)
std::vector< double > slopeT_
std::vector< std::string > wafers_
std::vector< int > layers_
DDName is used to identify DDD entities uniquely.
std::vector< std::string > materialsTop_
std::vector< int > layerTypeTop_
static std::string & ns()
Log< level::Error, false > LogError
HGCalGeomTools geomTools_
Compact representation of the geometrical detector hierarchy.
int32_t waferOrient(const int32_t property)
A DDSolid represents the shape of a part.
static std::string to_string(const XMLCh *ch)
std::vector< double > rMinFront_
static constexpr uint32_t k_CornerSize
Represents a uniquely identifyable rotation matrix.
U second(std::pair< T, U > const &p)
std::vector< double > thick_
std::vector< double > zFrontB_
std::vector< std::string > namesTop_
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
std::unordered_set< int > copies_
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 ...
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
int32_t waferThick(const int32_t property)
std::vector< double > layerThickTop_
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
std::vector< int > layerType_
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 > layerTypeBot_
std::vector< double > zFrontT_
std::vector< std::string > materialsBot_
std::vector< int > copyNumberTop_
void positionSensitive(const DDLogicalPart &glog, double rin, double rout, double zpos, int layertype, int layer, DDCompactView &cpv)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< int > copyNumberBot_
std::vector< int > layerCenter_
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
int32_t waferPartial(const int32_t property)
std::vector< int > layerSenseBot_
int32_t waferV(const int32_t index)
std::vector< int > waferIndex_
static int32_t packTypeUV(int type, int u, int v)
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< double > slopeB_
std::vector< std::string > names_
std::vector< int > waferProperty_
Log< level::Warning, false > LogWarning
void positionMix(const DDLogicalPart &glog, const std::string &name, int copy, double thick, const DDMaterial &matter, double rin, double rmid, double routF, double zz, DDCompactView &cpv)
void execute(DDCompactView &cpv) override
std::vector< double > layerThick_
std::vector< std::string > namesBot_
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
std::vector< double > layerThickBot_
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)
std::vector< std::string > materials_
std::vector< double > rMixLayer_