11 #include <unordered_set>
17 #include "DD4hep/DetFactoryHelper.h"
36 waferNames =
args.value<std::vector<std::string>>(
"WaferNames");
38 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << waferNames.size() <<
" wafers";
39 for (
unsigned int i = 0;
i < waferNames.size(); ++
i)
42 materials =
args.value<std::vector<std::string>>(
"MaterialNames");
43 volumeNames =
args.value<std::vector<std::string>>(
"VolumeNames");
45 for (
unsigned int i = 0;
i < materials.size(); ++
i) {
46 copyNumber.emplace_back(1);
49 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << materials.size() <<
" types of volumes";
50 for (
unsigned int i = 0;
i < volumeNames.size(); ++
i)
52 <<
" filled with " << materials[
i] <<
" first copy number " << copyNumber[
i];
54 layerNumbers =
args.value<std::vector<int>>(
"Layers");
55 layerThick =
args.value<std::vector<double>>(
"LayerThick");
56 rMixLayer =
args.value<std::vector<double>>(
"LayerRmix");
58 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerNumbers.size() <<
" blocks";
59 for (
unsigned int i = 0;
i < layerNumbers.size(); ++
i)
60 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick[
i] <<
" Rmid " << rMixLayer[
i]
61 <<
" with " << layerNumbers[
i] <<
" layers";
63 layerType =
args.value<std::vector<int>>(
"LayerType");
64 layerSense =
args.value<std::vector<int>>(
"LayerSense");
65 firstLayer =
args.value<
int>(
"FirstLayer");
66 absorbMode =
args.value<
int>(
"AbsorberMode");
69 <<
"Absober mode " << absorbMode;
71 layerCenter =
args.value<std::vector<int>>(
"LayerCenter");
73 for (
unsigned int i = 0;
i < layerCenter.size(); ++
i)
77 for (
unsigned int i = 0;
i < layerType.size(); ++
i) {
78 if (layerSense[
i] > 0) {
79 int ii = layerType[
i];
80 copyNumber[
ii] = firstLayer;
82 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with "
83 << materials[
ii] <<
" changed to " << copyNumber[
ii];
90 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType.size() <<
" layers";
91 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
92 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class "
95 materialsTop =
args.value<std::vector<std::string>>(
"TopMaterialNames");
96 namesTop =
args.value<std::vector<std::string>>(
"TopVolumeNames");
97 layerThickTop =
args.value<std::vector<double>>(
"TopLayerThickness");
98 layerTypeTop =
args.value<std::vector<int>>(
"TopLayerType");
99 for (
unsigned int i = 0;
i < materialsTop.size(); ++
i) {
100 copyNumberTop.emplace_back(1);
103 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << materialsTop.size() <<
" types of volumes in the top part";
104 for (
unsigned int i = 0;
i < materialsTop.size(); ++
i)
105 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesTop[
i] <<
" of thickness " << layerThickTop[
i]
106 <<
" filled with " << materialsTop[
i] <<
" first copy number " << copyNumberTop[
i];
107 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeTop.size() <<
" layers in the top part";
108 for (
unsigned int i = 0;
i < layerTypeTop.size(); ++
i)
109 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeTop[
i];
111 materialsBot =
args.value<std::vector<std::string>>(
"BottomMaterialNames");
112 namesBot =
args.value<std::vector<std::string>>(
"BottomVolumeNames");
113 layerTypeBot =
args.value<std::vector<int>>(
"BottomLayerType");
114 layerSenseBot =
args.value<std::vector<int>>(
"BottomLayerSense");
115 layerThickBot =
args.value<std::vector<double>>(
"BottomLayerThickness");
116 for (
unsigned int i = 0;
i < materialsBot.size(); ++
i) {
117 copyNumberBot.emplace_back(1);
120 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << materialsBot.size() <<
" types of volumes in the bottom part";
121 for (
unsigned int i = 0;
i < materialsBot.size(); ++
i)
122 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesBot[
i] <<
" of thickness " << layerThickBot[
i]
123 <<
" filled with " << materialsBot[
i] <<
" first copy number " << copyNumberBot[
i];
124 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeBot.size() <<
" layers in the bottom part";
125 for (
unsigned int i = 0;
i < layerTypeBot.size(); ++
i)
126 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeBot[
i]
127 <<
" sensitive class " << layerSenseBot[
i];
129 zMinBlock =
args.value<
double>(
"zMinBlock");
130 rad100to200 =
args.value<std::vector<double>>(
"rad100to200");
131 rad200to300 =
args.value<std::vector<double>>(
"rad200to300");
132 zMinRadPar =
args.value<
double>(
"zMinForRadPar");
133 choiceType =
args.value<
int>(
"choiceType");
134 nCutRadPar =
args.value<
int>(
"nCornerCut");
135 fracAreaMin =
args.value<
double>(
"fracAreaMin");
136 waferSize =
args.value<
double>(
"waferSize");
137 waferSepar =
args.value<
double>(
"SensorSeparation");
142 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: zStart " << zMinBlock <<
" radius for wafer type separation uses "
143 << rad100to200.size() <<
" parameters; zmin " << zMinRadPar <<
" cutoff "
144 << choiceType <<
":" << nCutRadPar <<
":" << fracAreaMin <<
" wafer width "
145 << waferSize <<
" separations " << waferSepar <<
" sectors " <<
sectors <<
":"
147 for (
unsigned int k = 0;
k < rad100to200.size(); ++
k)
148 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] 100-200 " << rad100to200[
k] <<
" 200-300 " << rad200to300[
k];
150 slopeB =
args.value<std::vector<double>>(
"SlopeBottom");
151 zFrontB =
args.value<std::vector<double>>(
"ZFrontBottom");
152 rMinFront =
args.value<std::vector<double>>(
"RMinFront");
153 slopeT =
args.value<std::vector<double>>(
"SlopeTop");
154 zFrontT =
args.value<std::vector<double>>(
"ZFrontTop");
155 rMaxFront =
args.value<std::vector<double>>(
"RMaxFront");
157 for (
unsigned int i = 0;
i < slopeB.size(); ++
i)
158 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontB[
i] <<
" Rmin " << rMinFront[
i]
159 <<
" Slope " << slopeB[
i];
160 for (
unsigned int i = 0;
i < slopeT.size(); ++
i)
161 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontT[
i] <<
" Rmax " << rMaxFront[
i]
162 <<
" Slope " << slopeT[
i];
166 waferType = std::make_unique<HGCalWaferType>(
167 rad100to200, rad200to300, (waferSize + waferSepar), zMinRadPar, choiceType, nCutRadPar, fracAreaMin);
174 double zi(zMinBlock);
176 const double tol(0.01);
177 for (
unsigned int i = 0;
i < layerNumbers.size();
i++) {
178 double zo = zi + layerThick[
i];
180 int laymax = laymin + layerNumbers[
i];
183 for (
int ly = laymin; ly < laymax; ++ly) {
184 int ii = layerType[ly];
185 int copy = copyNumber[
ii];
194 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " << routF
195 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick[
i];
201 if (layerSense[ly] < 1) {
202 std::vector<double> pgonZ, pgonRin, pgonRout;
203 if (layerSense[ly] == 0 || absorbMode == 0) {
206 pgonZ.emplace_back(-hthick);
207 pgonZ.emplace_back(hthick);
208 pgonRin.emplace_back(rinB);
209 pgonRin.emplace_back(rinB);
210 pgonRout.emplace_back(rmax);
211 pgonRout.emplace_back(rmax);
225 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
227 pgonRout[isec] = pgonRout[isec] * cosAlpha - tol;
239 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
241 <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
250 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.name() <<
" Tubs made of " << matter.name()
251 <<
" of dimensions " << rinB <<
", " << routF <<
", " << hthick
252 <<
", 0.0, 360.0 and positioned in: " << glog.name() <<
" number " <<
copy;
254 positionMix(ctxt,
e, glog,
name,
copy,
thickness[
ii], matter, rinB, rMixLayer[
i], routF,
zz);
258 mother.placeVolume(glog,
copy,
r1);
261 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << glog.name() <<
" number " <<
copy <<
" positioned in "
262 << mother.name() <<
" at " <<
r1 <<
" with no rotation";
268 if (
std::abs(thickTot - layerThick[
i]) < 0.00001) {
269 }
else if (thickTot > layerThick[
i]) {
270 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" is smaller than " << thickTot
271 <<
": thickness of all its "
272 <<
"components **** ERROR ****";
273 }
else if (thickTot < layerThick[
i]) {
274 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" does not match with "
275 << thickTot <<
" of the components";
280 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << copies.size() <<
" different wafer copy numbers";
282 for (std::unordered_set<int>::const_iterator
itr = copies.begin();
itr != copies.end(); ++
itr, ++
k) {
286 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalHEAlgo construction...";
304 for (
unsigned int ly = 0; ly < layerTypeTop.size(); ++ly) {
305 int ii = layerTypeTop[ly];
306 copyNumberTop[
ii] = copyM;
308 for (
unsigned int ly = 0; ly < layerTypeBot.size(); ++ly) {
309 int ii = layerTypeBot[ly];
310 copyNumberBot[
ii] = copyM;
312 double hthick = 0.5 * thick;
321 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.name() <<
" Tubs made of " << matter.name()
322 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthick <<
", 0.0, 360.0";
324 glog.placeVolume(glog1, 1);
327 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << glog1.name() <<
" number 1 positioned in " << glog.name()
328 <<
" at (0, 0, 0) with no rotation";
330 double thickTot(0), zpos(-hthick);
331 for (
unsigned int ly = 0; ly < layerTypeTop.size(); ++ly) {
332 int ii = layerTypeTop[ly];
333 int copy = copyNumberTop[
ii];
334 double hthickl = 0.5 * layerThickTop[
ii];
335 thickTot += layerThickTop[
ii];
338 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rmid <<
":" << rout
339 <<
" Thick " << layerThickTop[
ii];
353 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.name() <<
" Tubs made of " << matter1.name()
354 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthickl <<
", 0.0, 360.0";
359 glog1.placeVolume(glog2,
copy,
r1);
362 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Position " << glog2.name() <<
" number " <<
copy <<
" in "
363 << glog1.name() <<
" at " <<
r1 <<
" with no rotation";
368 if (
std::abs(thickTot - thick) < 0.00001) {
369 }
else if (thickTot > thick) {
370 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
371 <<
": thickness of all its components in "
372 <<
"the top part **** ERROR ****";
373 }
else if (thickTot < thick) {
374 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
375 <<
" of the components in top part";
379 name = nameM +
"Bottom";
387 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.name() <<
" Tubs made of " << matter.name()
388 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthick <<
", 0.0, 360.0";
391 glog.placeVolume(glog1, 1);
393 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << glog1.name() <<
" number 1 positioned in " << glog.name()
394 <<
" at (0, 0, 0) with no rotation";
398 for (
unsigned int ly = 0; ly < layerTypeBot.size(); ++ly) {
399 int ii = layerTypeBot[ly];
400 int copy = copyNumberBot[
ii];
401 double hthickl = 0.5 * layerThickBot[
ii];
402 thickTot += layerThickBot[
ii];
405 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rin <<
":" << rmid
406 <<
" Thick " << layerThickBot[
ii];
420 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.name() <<
" Tubs made of " << matter1.name()
421 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthickl <<
", 0.0, 360.0";
426 glog1.placeVolume(glog2,
copy,
r1);
428 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Position " << glog2.name() <<
" number " <<
copy <<
" in "
429 << glog1.name() <<
" at " <<
r1 <<
" with no rotation";
431 if (layerSenseBot[ly] != 0) {
434 << (
copy - firstLayer) <<
":" << layerCenter[
copy - firstLayer];
436 positionSensitive(ctxt,
e, glog2, rin, rmid,
zz + zpos, layerSenseBot[ly], layerCenter[
copy - firstLayer]);
441 if (
std::abs(thickTot - thick) < 0.00001) {
442 }
else if (thickTot > thick) {
443 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
444 <<
": thickness of all its components in "
445 <<
"the top part **** ERROR ****";
446 }
else if (thickTot < thick) {
447 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
448 <<
" of the components in top part";
461 static const double sqrt3 =
std::sqrt(3.0);
462 double r = 0.5 * (waferSize + waferSepar);
463 double R = 2.0 *
r / sqrt3;
464 double dy = 0.75 *
R;
465 int N = (
int)(0.5 * rout /
r) + 2;
466 std::pair<double, double> xyoff = geomTools.shiftXY(layercenter, (waferSize + waferSepar));
468 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0),
nin(0);
469 std::vector<int> ntype(6, 0);
470 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << glog.name() <<
" rout " << rout <<
" N " <<
N
471 <<
" for maximum u, v Offset; Shift " << xyoff.first <<
":" << xyoff.second
472 <<
" WaferSize " << (waferSize + waferSepar);
474 for (
int u = -
N; u <=
N; ++u) {
476 for (
int v = -
N;
v <=
N; ++
v) {
480 double xpos = xyoff.first + nc *
r;
481 double ypos = xyoff.second +
nr *
dy;
487 int type = waferType->getType(xpos, ypos, zpos);
488 int copy =
type * 1000000 + iv * 100 + iu;
499 if (copies.count(
copy) == 0)
518 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << glog.name() <<
" number " <<
copy <<
" positioned in "
519 << glog.name() <<
" at " << tran <<
" with no rotation";
526 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
527 <<
":" << ivmAll <<
" and " <<
nin <<
":" << kount <<
":" << ntot <<
" wafers ("
528 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":"
529 << ntype[4] <<
":" << ntype[5] <<
") for " << glog.name() <<
" R " << rin <<
":"
586 dd4hep::SensitiveDetector& ) {