9 #include <unordered_set>
18 #include "DD4hep/DetFactoryHelper.h"
36 static constexpr
double tol1 = 0.01 * dd4hep::mm;
37 static constexpr
double tol2 = 0.00001 * dd4hep::mm;
40 wafers_ =
args.value<std::vector<std::string>>(
"WaferNames");
42 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << wafers_.size() <<
" wafers";
43 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
46 materials_ =
args.value<std::vector<std::string>>(
"MaterialNames");
47 names_ =
args.value<std::vector<std::string>>(
"VolumeNames");
48 thick_ =
args.value<std::vector<double>>(
"Thickness");
49 copyNumber_.resize(materials_.size(), 1);
51 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << materials_.size() <<
" types of volumes";
52 for (
unsigned int i = 0;
i < names_.size(); ++
i)
53 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness "
55 <<
" first copy number " << copyNumber_[
i];
57 layers_ =
args.value<std::vector<int>>(
"Layers");
58 layerThick_ =
args.value<std::vector<double>>(
"LayerThick");
60 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
61 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
63 <<
" with " << layers_[
i] <<
" layers";
65 layerType_ =
args.value<std::vector<int>>(
"LayerType");
66 layerSense_ =
args.value<std::vector<int>>(
"LayerSense");
67 firstLayer_ =
args.value<
int>(
"FirstLayer");
68 absorbMode_ =
args.value<
int>(
"AbsorberMode");
69 sensitiveMode_ =
args.value<
int>(
"SensitiveMode");
72 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
74 layerCenter_ =
args.value<std::vector<int>>(
"LayerCenter");
76 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
79 if (firstLayer_ > 0) {
80 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
81 if (layerSense_[
i] > 0) {
82 int ii = layerType_[
i];
83 copyNumber_[
ii] = firstLayer_;
85 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with "
86 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
95 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
96 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
97 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
100 zMinBlock_ =
args.value<
double>(
"zMinBlock");
101 waferSize_ =
args.value<
double>(
"waferSize");
102 waferSepar_ =
args.value<
double>(
"SensorSeparation");
103 sectors_ =
args.value<
int>(
"Sectors");
104 alpha_ = (1._pi) / sectors_;
105 cosAlpha_ =
cos(alpha_);
109 <<
" sectors " << sectors_ <<
":" <<
convertRadToDeg(alpha_) <<
":" << cosAlpha_;
111 waferIndex_ =
args.value<std::vector<int>>(
"WaferIndex");
112 waferProperty_ =
args.value<std::vector<int>>(
"WaferProperties");
114 edm::LogVerbatim(
"HGCalGeom") <<
"waferProperties with " << waferIndex_.size() <<
" entries";
115 for (
unsigned int k = 0;
k < waferIndex_.size(); ++
k)
124 slopeB_ =
args.value<std::vector<double>>(
"SlopeBottom");
125 zFrontB_ =
args.value<std::vector<double>>(
"ZFrontBottom");
126 rMinFront_ =
args.value<std::vector<double>>(
"RMinFront");
127 slopeT_ =
args.value<std::vector<double>>(
"SlopeTop");
128 zFrontT_ =
args.value<std::vector<double>>(
"ZFrontTop");
129 rMaxFront_ =
args.value<std::vector<double>>(
"RMaxFront");
131 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
134 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
145 double zi(zMinBlock_);
147 for (
unsigned int i = 0;
i < layers_.size(); ++
i) {
148 double zo = zi + layerThick_[
i];
150 int laymax = laymin + layers_[
i];
153 for (
int ly = laymin; ly < laymax; ++ly) {
154 int ii = layerType_[ly];
155 int copy = copyNumber_[
ii];
156 double hthick = 0.5 * thick_[
ii];
159 thickTot += thick_[
ii];
163 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: Layer " << ly <<
":" <<
ii <<
" Front "
172 if (layerSense_[ly] < 1) {
173 std::vector<double> pgonZ, pgonRin, pgonRout;
174 double rmax = routF * cosAlpha_ - tol1;
187 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
189 if (layerSense_[ly] == 0 || absorbMode_ == 0)
190 pgonRout[isec] = rmax;
192 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1;
194 dd4hep::Solid solid =
dd4hep::Polyhedra(sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
199 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << solid.name() <<
" polyhedra of " << sectors_
202 <<
" sections and filled with " << matter.name();
203 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
212 dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi);
218 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << solid.name() <<
" Tubs made of " << matter.name()
221 <<
cms::convert2mm(hthick) <<
", 0.0, 360.0 and position " << glog.name()
222 <<
" number " <<
copy <<
":" << layerCenter_[
copy - firstLayer_];
224 positionSensitive(ctxt,
e, glog, rins, routs,
zz, layerSense_[ly], (
copy - firstLayer_));
228 mother.placeVolume(glog,
copy,
r1);
231 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << glog.name() <<
" number " <<
copy <<
" positioned in "
239 if (
std::abs(thickTot - layerThick_[
i]) >= tol2) {
240 if (thickTot > layerThick_[
i]) {
243 <<
": thickness of all its components **** ERROR ****";
246 <<
" does not match with " <<
cms::convert2mm(thickTot) <<
" of the components";
252 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << copies_.size() <<
" different wafer copy numbers";
254 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
258 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalEEFileAlgo construction...";
271 static const double sqrt3 =
std::sqrt(3.0);
272 int layercenter = layerCenter_[
layer];
273 double r = 0.5 * (waferSize_ + waferSepar_);
274 double R = 2.0 *
r / sqrt3;
275 double dy = 0.75 *
R;
276 int N = (
int)(0.5 * rout /
r) + 2;
277 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
279 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0),
ntot(0),
nin(0);
280 std::vector<int> ntype(6, 0);
288 for (
int u = -
N; u <=
N; ++u) {
289 for (
int v = -
N;
v <=
N; ++
v) {
296 double xpos = xyoff.first + nc *
r;
297 double ypos = xyoff.second +
nr *
dy;
304 << layertype <<
" u " << u <<
" v " <<
v <<
" with " <<
corner.first
314 <<
type <<
" layer:u:v:indx " << (
layer + firstLayer_) <<
":" << u <<
":" <<
v
321 if (copies_.count(
copy) == 0)
322 copies_.insert(
copy);
339 <<
" DDHGCalEEFileAlgo: " << wafers_[
type] <<
" number " <<
copy <<
" type " << layertype <<
":" <<
type
341 <<
", 0) with no rotation";
349 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
350 <<
":" << ivmAll <<
" and " <<
nin <<
":" << kount <<
":" <<
ntot <<
" wafers ("
351 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":"
352 << ntype[4] <<
":" << ntype[5] <<
") for " << glog.name() <<
" R "