13 #include <unordered_set>
18 #include "DD4hep/DetFactoryHelper.h"
70 wafers_ =
args.value<std::vector<std::string>>(
"WaferNames");
72 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << wafers_.size() <<
" wafers";
73 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
77 materials_ =
args.value<std::vector<std::string>>(
"MaterialNames");
78 names_ =
args.value<std::vector<std::string>>(
"VolumeNames");
79 thick_ =
args.value<std::vector<double>>(
"Thickness");
80 for (
unsigned int i = 0;
i < materials_.size(); ++
i) {
81 copyNumber_.emplace_back(1);
84 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << materials_.size() <<
" types of volumes";
85 for (
unsigned int i = 0;
i < names_.size(); ++
i)
86 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
87 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
90 layers_ =
args.value<std::vector<int>>(
"Layers");
91 layerThick_ =
args.value<std::vector<double>>(
"LayerThick");
93 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
94 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
95 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" with " << layers_[
i]
99 layerType_ =
args.value<std::vector<int>>(
"LayerType");
100 layerSense_ =
args.value<std::vector<int>>(
"LayerSense");
101 firstLayer_ =
args.value<
int>(
"FirstLayer");
102 absorbMode_ =
args.value<
int>(
"AbsorberMode");
106 <<
"Absober mode " << absorbMode_;
108 layerCenter_ =
args.value<std::vector<int>>(
"LayerCenter");
110 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
113 if (firstLayer_ > 0) {
114 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
115 if (layerSense_[
i] > 0) {
116 int ii = layerType_[
i];
117 copyNumber_[
ii] = firstLayer_;
119 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with "
120 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
127 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
128 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
129 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
132 zMinBlock_ =
args.value<
double>(
"zMinBlock");
134 rad100to200_ =
args.value<std::vector<double>>(
"rad100to200");
135 rad200to300_ =
args.value<std::vector<double>>(
"rad200to300");
136 zMinRadPar_ =
args.value<
double>(
"zMinForRadPar");
137 choiceType_ =
args.value<
int>(
"choiceType");
138 nCutRadPar_ =
args.value<
int>(
"nCornerCut");
139 fracAreaMin_ =
args.value<
double>(
"fracAreaMin");
140 waferSize_ =
args.value<
double>(
"waferSize");
141 waferSepar_ =
args.value<
double>(
"SensorSeparation");
142 sectors_ =
args.value<
int>(
"Sectors");
143 alpha_ = (1._pi) / sectors_;
144 cosAlpha_ =
cos(alpha_);
146 edm::LogVerbatim(
"HGCalGeom") <<
"zStart " << zMinBlock_ <<
" radius for wafer type separation uses "
147 << rad100to200_.size() <<
" parameters; zmin " << zMinRadPar_ <<
" cutoff "
148 << choiceType_ <<
":" << nCutRadPar_ <<
":" << fracAreaMin_ <<
" wafer width "
149 << waferSize_ <<
" separations " << waferSepar_ <<
" sectors " << sectors_ <<
":"
151 for (
unsigned int k = 0;
k < rad100to200_.size(); ++
k)
152 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] 100-200 " << rad100to200_[
k] <<
" 200-300 " << rad200to300_[
k];
155 slopeB_ =
args.value<std::vector<double>>(
"SlopeBottom");
156 zFrontB_ =
args.value<std::vector<double>>(
"ZFrontBottom");
157 rMinFront_ =
args.value<std::vector<double>>(
"RMinFront");
158 slopeT_ =
args.value<std::vector<double>>(
"SlopeTop");
159 zFrontT_ =
args.value<std::vector<double>>(
"ZFrontTop");
160 rMaxFront_ =
args.value<std::vector<double>>(
"RMaxFront");
162 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
163 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
164 <<
" Slope " << slopeB_[
i];
165 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
166 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
167 <<
" Slope " << slopeT_[
i];
174 waferType_ = std::make_unique<HGCalWaferType>(
175 rad100to200_, rad200to300_, (waferSize_ + waferSepar_), zMinRadPar_, choiceType_, nCutRadPar_, fracAreaMin_);
177 ConstructAlgo(ctxt,
e);
186 ConstructLayers(par, ctxt,
e);
188 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << copies_.size() <<
" different wafer copy numbers";
190 for (std::unordered_set<int>::const_iterator
itr = copies_.begin();
itr != copies_.end(); ++
itr, ++
k) {
194 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalEEAlgo construction...";
205 double zi(zMinBlock_);
207 const double tol(0.01);
208 for (
unsigned int i = 0;
i < layers_.size();
i++) {
209 double zo = zi + layerThick_[
i];
211 int laymax = laymin + layers_[
i];
214 for (
int ly = laymin; ly < laymax; ++ly) {
215 int ii = layerType_[ly];
216 int copy = copyNumber_[
ii];
217 double hthick = 0.5 * thick_[
ii];
220 thickTot += thick_[
ii];
224 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " << routF
225 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick_[
i];
231 if (layerSense_[ly] < 1) {
232 std::vector<double> pgonZ, pgonRin, pgonRout;
233 if (layerSense_[ly] == 0 || absorbMode_ == 0) {
234 double rmax = routF * cosAlpha_ - tol;
235 pgonZ.emplace_back(-hthick);
236 pgonZ.emplace_back(hthick);
237 pgonRin.emplace_back(rinB);
238 pgonRin.emplace_back(rinB);
239 pgonRout.emplace_back(rmax);
240 pgonRout.emplace_back(rmax);
255 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: z " << (
zz - hthick) <<
":" << (
zz + hthick) <<
" with "
256 << pgonZ.size() <<
" palnes";
257 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec)
259 <<
"[" << isec <<
"] z " << pgonZ[isec] <<
" R " << pgonRin[isec] <<
":" << pgonRout[isec];
261 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
263 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol;
267 dd4hep::Solid solid =
274 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << solid.name() <<
" polyhedra of " << sectors_
277 <<
" sections and filled with " << matName;
279 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
281 <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
290 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << solid.name() <<
" Tubs made of " << matName
291 <<
" of dimensions " << rinB <<
", " << routF <<
", " << hthick
292 <<
", 0.0, 360.0 and position " << glog.name() <<
" number " <<
copy <<
":"
293 << layerCenter_[
copy - 1];
295 PositionSensitive(ctxt,
e, glog, rinB, routF,
zz, layerSense_[ly], layerCenter_[
copy - 1]);
299 mother_.placeVolume(glog,
copy,
r1);
303 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << glog.name() <<
" number " <<
copy <<
" positioned in "
304 <<
module.name() <<
" at " <<
r1 <<
" with no rotation";
310 if (
std::abs(thickTot - layerThick_[
i]) < 0.00001) {
311 }
else if (thickTot > layerThick_[
i]) {
312 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
313 <<
": thickness of all its "
314 <<
"components **** ERROR ****";
315 }
else if (thickTot < layerThick_[
i]) {
316 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with "
317 << thickTot <<
" of the components";
332 static const double sqrt3 =
std::sqrt(3.0);
333 double r = 0.5 * (waferSize_ + waferSepar_);
334 double R = 2.0 *
r / sqrt3;
335 double dy = 0.75 *
R;
336 int N = (
int)(0.5 * rout /
r) + 2;
337 std::pair<double, double> xyoff = geomTools_.
shiftXY(layercenter, (waferSize_ + waferSepar_));
339 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0),
nin(0);
340 std::vector<int> ntype(6, 0);
341 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << glog.name() <<
" rout " << rout <<
" N " <<
N
342 <<
" for maximum u, v; r " <<
r <<
" R " <<
R <<
" dy " <<
dy <<
" Shift "
343 << xyoff.first <<
":" << xyoff.second <<
" WaferSize " << (waferSize_ + waferSepar_);
346 for (
int u = -
N; u <=
N; ++u) {
348 for (
int v = -
N;
v <=
N; ++
v) {
352 double xpos = xyoff.first + nc *
r;
353 double ypos = xyoff.second +
nr *
dy;
358 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << glog.name() <<
" R " << rin <<
":" << rout <<
"\n Z "
359 << zpos <<
" LayerType " << layertype <<
" u " << u <<
" v " <<
v <<
" with "
360 <<
corner.first <<
" corners";
364 int type = waferType_->getType(xpos, ypos, zpos);
365 int copy =
type * 1000000 + iv * 100 + iu;
376 if (copies_.count(
copy) == 0)
377 copies_.insert(
copy);
395 <<
" positioned in " << glog.name() <<
" at " << tran <<
" with no rotation";
403 edm::LogVerbatim(
"HGCalGeom") <<
" DDHGCalEEAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
404 <<
":" << ivmAll <<
" and " <<
nin <<
":" << kount <<
":" << ntot <<
" wafers ("
405 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":"
406 << ntype[4] <<
":" << ntype[5] <<
") for " << glog.name() <<
" R " << rin <<
":"
415 dd4hep::SensitiveDetector& ) {