13 #include <unordered_set>
16 #include "DD4hep/DetFactoryHelper.h"
72 wafers_ =
args.value<std::vector<std::string>>(
"WaferNames");
74 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << wafers_.size() <<
" wafers";
75 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
79 materials_ =
args.value<std::vector<std::string>>(
"MaterialNames");
80 names_ =
args.value<std::vector<std::string>>(
"VolumeNames");
81 thick_ =
args.value<std::vector<double>>(
"Thickness");
82 copyNumber_.resize(materials_.size(), 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");
103 sensitiveMode_ =
args.value<
int>(
"SensitiveMode");
106 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
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];
129 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
130 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
131 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
134 zMinBlock_ =
args.value<
double>(
"zMinBlock");
136 rad100to200_ =
args.value<std::vector<double>>(
"rad100to200");
137 rad200to300_ =
args.value<std::vector<double>>(
"rad200to300");
138 zMinRadPar_ =
args.value<
double>(
"zMinForRadPar");
139 choiceType_ =
args.value<
int>(
"choiceType");
140 nCutRadPar_ =
args.value<
int>(
"nCornerCut");
141 fracAreaMin_ =
args.value<
double>(
"fracAreaMin");
142 waferSize_ =
args.value<
double>(
"waferSize");
143 waferSepar_ =
args.value<
double>(
"SensorSeparation");
144 sectors_ =
args.value<
int>(
"Sectors");
145 alpha_ = (1._pi) / sectors_;
146 cosAlpha_ =
cos(alpha_);
148 edm::LogVerbatim(
"HGCalGeom") <<
"zStart " << zMinBlock_ <<
" radius for wafer type separation uses "
149 << rad100to200_.size() <<
" parameters; zmin " << zMinRadPar_ <<
" cutoff "
150 << choiceType_ <<
":" << nCutRadPar_ <<
":" << fracAreaMin_ <<
" wafer width "
151 << waferSize_ <<
" separations " << waferSepar_ <<
" sectors " << sectors_ <<
":"
153 for (
unsigned int k = 0;
k < rad100to200_.size(); ++
k)
154 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] 100-200 " << rad100to200_[
k] <<
" 200-300 " << rad200to300_[
k];
157 slopeB_ =
args.value<std::vector<double>>(
"SlopeBottom");
158 zFrontB_ =
args.value<std::vector<double>>(
"ZFrontBottom");
159 rMinFront_ =
args.value<std::vector<double>>(
"RMinFront");
160 slopeT_ =
args.value<std::vector<double>>(
"SlopeTop");
161 zFrontT_ =
args.value<std::vector<double>>(
"ZFrontTop");
162 rMaxFront_ =
args.value<std::vector<double>>(
"RMaxFront");
164 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
165 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
166 <<
" Slope " << slopeB_[
i];
167 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
168 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
169 <<
" Slope " << slopeT_[
i];
176 waferType_ = std::make_unique<HGCalWaferType>(
177 rad100to200_, rad200to300_, (waferSize_ + waferSepar_), zMinRadPar_, choiceType_, nCutRadPar_, fracAreaMin_);
179 ConstructAlgo(ctxt,
e);
188 ConstructLayers(par, ctxt,
e);
190 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << copies_.size() <<
" different wafer copy numbers";
192 for (std::unordered_set<int>::const_iterator
itr = copies_.begin();
itr != copies_.end(); ++
itr, ++
k) {
196 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalEEAlgo construction...";
201 static constexpr
double tol1 = 0.01;
202 static constexpr
double tol2 = 0.00001;
209 double zi(zMinBlock_);
211 for (
unsigned int i = 0;
i < layers_.size();
i++) {
212 double zo = zi + layerThick_[
i];
214 int laymax = laymin + layers_[
i];
217 for (
int ly = laymin; ly < laymax; ++ly) {
218 int ii = layerType_[ly];
219 int copy = copyNumber_[
ii];
220 double hthick = 0.5 * thick_[
ii];
223 thickTot += thick_[
ii];
227 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " << routF
228 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick_[
i];
234 if (layerSense_[ly] < 1) {
235 std::vector<double> pgonZ, pgonRin, pgonRout;
236 if (layerSense_[ly] == 0 || absorbMode_ == 0) {
237 double rmax = routF * cosAlpha_ - tol1;
238 pgonZ.emplace_back(-hthick);
239 pgonZ.emplace_back(hthick);
240 pgonRin.emplace_back(rinB);
241 pgonRin.emplace_back(rinB);
242 pgonRout.emplace_back(rmax);
243 pgonRout.emplace_back(rmax);
258 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: z " << (
zz - hthick) <<
":" << (
zz + hthick) <<
" with "
259 << pgonZ.size() <<
" palnes";
260 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec)
262 <<
"[" << isec <<
"] z " << pgonZ[isec] <<
" R " << pgonRin[isec] <<
":" << pgonRout[isec];
264 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
266 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1;
270 dd4hep::Solid solid =
277 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << solid.name() <<
" polyhedra of " << sectors_
280 <<
" sections and filled with " << matName;
282 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
284 <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
291 dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi);
297 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << solid.name() <<
" Tubs made of " << matter.name()
298 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
299 <<
", " << hthick <<
", 0.0, 360.0 and position " << glog.name() <<
" number "
300 <<
copy <<
":" << layerCenter_[
copy - firstLayer_];
303 ctxt,
e, glog, rins, routs,
zz, layerSense_[ly], layerCenter_[
copy - firstLayer_]);
307 mother_.placeVolume(glog,
copy,
r1);
311 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << glog.name() <<
" number " <<
copy <<
" positioned in "
312 << module.name() <<
" at " <<
r1 <<
" with no rotation";
318 if (
std::abs(thickTot - layerThick_[
i]) >= tol2) {
319 if (thickTot > layerThick_[
i]) {
320 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than "
321 << thickTot <<
": thickness of all its components **** ERROR ****";
323 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with "
324 << thickTot <<
" of the components";
340 static const double sqrt3 =
std::sqrt(3.0);
341 double r = 0.5 * (waferSize_ + waferSepar_);
342 double R = 2.0 *
r / sqrt3;
343 double dy = 0.75 *
R;
344 int N = (
int)(0.5 * rout /
r) + 2;
345 const auto& xyoff = geomTools_.
shiftXY(layercenter, (waferSize_ + waferSepar_));
347 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0),
nin(0);
348 std::vector<int> ntype(6, 0);
349 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << glog.name() <<
" rout " << rout <<
" N " <<
N
350 <<
" for maximum u, v; r " <<
r <<
" R " <<
R <<
" dy " <<
dy <<
" Shift "
351 << xyoff.first <<
":" << xyoff.second <<
" WaferSize " << (waferSize_ + waferSepar_);
354 for (
int u = -
N; u <=
N; ++u) {
355 for (
int v = -
N;
v <=
N; ++
v) {
358 double xpos = xyoff.first + nc *
r;
359 double ypos = xyoff.second +
nr *
dy;
366 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << glog.name() <<
" R " << rin <<
":" << rout <<
"\n Z "
367 << zpos <<
" LayerType " << layertype <<
" u " << u <<
" v " <<
v <<
" with "
368 <<
corner.first <<
" corners";
372 int type = waferType_->getType(xpos, ypos, zpos);
380 if (copies_.count(
copy) == 0)
381 copies_.insert(
copy);
399 <<
" positioned in " << glog.name() <<
" at " << tran <<
" with no rotation";
407 edm::LogVerbatim(
"HGCalGeom") <<
" DDHGCalEEAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
408 <<
":" << ivmAll <<
" and " <<
nin <<
":" << kount <<
":" << ntot <<
" wafers ("
409 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":"
410 << ntype[4] <<
":" << ntype[5] <<
") for " << glog.name() <<
" R " << rin <<
":"