9 #include <unordered_set>
17 #include "DD4hep/DetFactoryHelper.h"
34 static constexpr
double tol1 = 0.01;
35 static constexpr
double tol2 = 0.00001;
38 wafers_ =
args.value<std::vector<std::string>>(
"WaferNames");
40 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << wafers_.size() <<
" wafers";
41 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
44 materials_ =
args.value<std::vector<std::string>>(
"MaterialNames");
45 names_ =
args.value<std::vector<std::string>>(
"VolumeNames");
46 thick_ =
args.value<std::vector<double>>(
"Thickness");
47 copyNumber_.resize(materials_.size(), 1);
49 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << materials_.size() <<
" types of volumes";
50 for (
unsigned int i = 0;
i < names_.size(); ++
i)
51 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
52 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
54 layers_ =
args.value<std::vector<int>>(
"Layers");
55 layerThick_ =
args.value<std::vector<double>>(
"LayerThick");
57 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
58 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
59 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" with " << layers_[
i]
62 layerType_ =
args.value<std::vector<int>>(
"LayerType");
63 layerSense_ =
args.value<std::vector<int>>(
"LayerSense");
64 firstLayer_ =
args.value<
int>(
"FirstLayer");
65 absorbMode_ =
args.value<
int>(
"AbsorberMode");
66 sensitiveMode_ =
args.value<
int>(
"SensitiveMode");
69 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
71 layerCenter_ =
args.value<std::vector<int>>(
"LayerCenter");
73 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
76 if (firstLayer_ > 0) {
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];
92 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
93 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
94 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
97 zMinBlock_ =
args.value<
double>(
"zMinBlock");
98 rad100to200_ =
args.value<std::vector<double>>(
"rad100to200");
99 rad200to300_ =
args.value<std::vector<double>>(
"rad200to300");
100 zMinRadPar_ =
args.value<
double>(
"zMinForRadPar");
101 choiceType_ =
args.value<
int>(
"choiceType");
102 nCutRadPar_ =
args.value<
int>(
"nCornerCut");
103 fracAreaMin_ =
args.value<
double>(
"fracAreaMin");
104 waferSize_ =
args.value<
double>(
"waferSize");
105 waferSepar_ =
args.value<
double>(
"SensorSeparation");
106 sectors_ =
args.value<
int>(
"Sectors");
107 alpha_ = (1._pi) / sectors_;
108 cosAlpha_ =
cos(alpha_);
110 edm::LogVerbatim(
"HGCalGeom") <<
"zStart " << zMinBlock_ <<
" radius for wafer type separation uses "
111 << rad100to200_.size() <<
" parameters; zmin " << zMinRadPar_ <<
" cutoff "
112 << choiceType_ <<
":" << nCutRadPar_ <<
":" << fracAreaMin_ <<
" wafer width "
113 << waferSize_ <<
" separations " << waferSepar_ <<
" sectors " << sectors_ <<
":"
115 for (
unsigned int k = 0;
k < rad100to200_.size(); ++
k)
116 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] 100-200 " << rad100to200_[
k] <<
" 200-300 " << rad200to300_[
k];
118 waferIndex_ =
args.value<std::vector<int>>(
"WaferIndex");
119 waferTypes_ =
args.value<std::vector<int>>(
"WaferTypes");
121 edm::LogVerbatim(
"HGCalGeom") <<
"waferTypes with " << waferTypes_.size() <<
" entries";
122 for (
unsigned int k = 0;
k < waferTypes_.size(); ++
k)
128 slopeB_ =
args.value<std::vector<double>>(
"SlopeBottom");
129 zFrontB_ =
args.value<std::vector<double>>(
"ZFrontBottom");
130 rMinFront_ =
args.value<std::vector<double>>(
"RMinFront");
131 slopeT_ =
args.value<std::vector<double>>(
"SlopeTop");
132 zFrontT_ =
args.value<std::vector<double>>(
"ZFrontTop");
133 rMaxFront_ =
args.value<std::vector<double>>(
"RMaxFront");
135 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
136 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
137 <<
" Slope " << slopeB_[
i];
138 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
139 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
140 <<
" Slope " << slopeT_[
i];
149 double zi(zMinBlock_);
151 for (
unsigned int i = 0;
i < layers_.size(); ++
i) {
152 double zo = zi + layerThick_[
i];
154 int laymax = laymin + layers_[
i];
157 for (
int ly = laymin; ly < laymax; ++ly) {
158 int ii = layerType_[ly];
159 int copy = copyNumber_[
ii];
160 double hthick = 0.5 * thick_[
ii];
163 thickTot += thick_[
ii];
167 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", "
168 << routF <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness "
175 if (layerSense_[ly] < 1) {
176 std::vector<double> pgonZ, pgonRin, pgonRout;
177 if (layerSense_[ly] == 0 || absorbMode_ == 0) {
178 double rmax = routF * cosAlpha_ - tol1;
179 pgonZ.emplace_back(-hthick);
180 pgonZ.emplace_back(hthick);
181 pgonRin.emplace_back(rinB);
182 pgonRin.emplace_back(rinB);
183 pgonRout.emplace_back(rmax);
184 pgonRout.emplace_back(rmax);
199 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: z " << (
zz - hthick) <<
":" << (
zz + hthick)
200 <<
" with " << pgonZ.size() <<
" palnes";
201 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec)
203 <<
"[" << isec <<
"] z " << pgonZ[isec] <<
" R " << pgonRin[isec] <<
":" << pgonRout[isec];
205 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
207 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1;
210 dd4hep::Solid solid =
dd4hep::Polyhedra(sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
215 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << solid.name() <<
" polyhedra of " << sectors_
218 <<
" sections and filled with " << matter.name();
219 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
221 <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
228 dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi);
234 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << solid.name() <<
" Tubs made of " << matter.name()
235 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
236 <<
", " << hthick <<
", 0.0, 360.0 and position " << glog.name() <<
" number "
237 <<
copy <<
":" << layerCenter_[
copy - firstLayer_];
239 positionSensitive(ctxt,
e, glog, rins, routs,
zz, layerSense_[ly], (
copy - firstLayer_));
243 mother.placeVolume(glog,
copy,
r1);
246 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << glog.name() <<
" number " <<
copy <<
" positioned in "
247 << mother.name() <<
" at " <<
r1 <<
" with no rotation";
254 if (
std::abs(thickTot - layerThick_[
i]) >= tol2) {
255 if (thickTot > layerThick_[
i]) {
256 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than "
257 << thickTot <<
": thickness of all its components **** ERROR ****";
259 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with "
260 << thickTot <<
" of the components";
266 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << 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 DDHGCalEEFileAlgo construction...";
285 static const double sqrt3 =
std::sqrt(3.0);
286 int layercenter = layerCenter_[layer];
287 double r = 0.5 * (waferSize_ + waferSepar_);
288 double R = 2.0 *
r / sqrt3;
289 double dy = 0.75 *
R;
290 int N = (
int)(0.5 * rout /
r) + 2;
291 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
293 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0),
nin(0);
294 std::vector<int> ntype(6, 0);
295 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << glog.name() <<
" rin:rout " << rin <<
":" << rout
296 <<
" zpos " << zpos <<
" N " <<
N <<
" for maximum u, v; r " <<
r <<
" R " <<
R
297 <<
" dy " <<
dy <<
" Shift " << xyoff.first <<
":" << xyoff.second <<
" WaferSize "
298 << (waferSize_ + waferSepar_);
300 for (
int u = -
N; u <=
N; ++u) {
301 for (
int v = -
N;
v <=
N; ++
v) {
308 double xpos = xyoff.first + nc *
r;
309 double ypos = xyoff.second +
nr *
dy;
314 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << glog.name() <<
" R " << rin <<
":" << rout
315 <<
"\n Z " << zpos <<
" LayerType " << layertype <<
" u " << u <<
" v " <<
v
316 <<
" with " <<
corner.first <<
" corners";
325 <<
type <<
" layer:u:v:indx " << (layer + firstLayer_) <<
":" << u <<
":" <<
v
332 if (copies_.count(
copy) == 0)
333 copies_.insert(
copy);
350 <<
" DDHGCalEEFileAlgo: " << wafers_[
type] <<
" number " <<
copy <<
" type " << layertype <<
":" <<
type
351 <<
" positioned in " << glog.name() <<
" at " << tran <<
" with no rotation";
359 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
360 <<
":" << ivmAll <<
" and " <<
nin <<
":" << kount <<
":" << ntot <<
" wafers ("
361 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":"
362 << ntype[4] <<
":" << ntype[5] <<
") for " << glog.name() <<
" R " << rin <<
":"