10 #include <unordered_set>
19 #include "DD4hep/DetFactoryHelper.h"
35 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: Creating an instance";
37 static constexpr
double tol1 = 0.01 * dd4hep::mm;
38 static constexpr
double tol2 = 0.00001 * dd4hep::mm;
41 waferTypes_ =
args.value<
int>(
"WaferTypes");
42 facingTypes_ =
args.value<
int>(
"FacingTypes");
43 partialTypes_ =
args.value<
int>(
"PartialTypes");
44 orientationTypes_ =
args.value<
int>(
"OrientationTypes");
46 edm::LogVerbatim(
"HGCalGeom") <<
"Number of types of wafers: " << waferTypes_ <<
" facings: " << facingTypes_
47 <<
" partials: " << partialTypes_ <<
" Orientations: " << orientationTypes_;
49 firstLayer_ =
args.value<
int>(
"FirstLayer");
50 absorbMode_ =
args.value<
int>(
"AbsorberMode");
51 sensitiveMode_ =
args.value<
int>(
"SensitiveMode");
54 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
56 zMinBlock_ =
args.value<
double>(
"zMinBlock");
57 waferSize_ =
args.value<
double>(
"waferSize");
58 waferSepar_ =
args.value<
double>(
"SensorSeparation");
59 sectors_ =
args.value<
int>(
"Sectors");
60 alpha_ = (1._pi) / sectors_;
61 cosAlpha_ =
cos(alpha_);
65 <<
" sectors " << sectors_ <<
":" <<
convertRadToDeg(alpha_) <<
":" << cosAlpha_;
67 waferFull_ =
args.value<std::vector<std::string>>(
"WaferNamesFull");
68 waferPart_ =
args.value<std::vector<std::string>>(
"WaferNamesPartial");
70 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << waferFull_.size() <<
" full and " << waferPart_.size()
71 <<
" partial modules\nDDHGCalSiliconModule:Full Modules:";
72 unsigned int i1max = static_cast<unsigned int>(waferFull_.size());
73 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
74 std::ostringstream st1;
76 for (
unsigned int i =
i1;
i <
i2; ++
i)
77 st1 <<
" [" <<
i <<
"] " << waferFull_[
i];
81 i1max = static_cast<unsigned int>(waferPart_.size());
82 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
83 std::ostringstream st1;
85 for (
unsigned int i =
i1;
i <
i2; ++
i)
86 st1 <<
" [" <<
i <<
"] " << waferPart_[
i];
90 materials_ =
args.value<std::vector<std::string>>(
"MaterialNames");
91 names_ =
args.value<std::vector<std::string>>(
"VolumeNames");
92 thick_ =
args.value<std::vector<double>>(
"Thickness");
93 copyNumber_.resize(materials_.size(), 1);
95 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << materials_.size() <<
" types of volumes";
96 for (
unsigned int i = 0;
i < names_.size(); ++
i)
97 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness "
99 <<
" first copy number " << copyNumber_[
i];
101 layers_ =
args.value<std::vector<int>>(
"Layers");
102 layerThick_ =
args.value<std::vector<double>>(
"LayerThick");
104 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
105 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
107 <<
" with " << layers_[
i] <<
" layers";
109 layerType_ =
args.value<std::vector<int>>(
"LayerType");
110 layerSense_ =
args.value<std::vector<int>>(
"LayerSense");
111 layerCenter_ =
args.value<std::vector<int>>(
"LayerCenter");
113 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
116 if (firstLayer_ > 0) {
117 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
118 if (layerSense_[
i] > 0) {
119 int ii = layerType_[
i];
120 copyNumber_[
ii] = (layerSense_[
i] == 1) ? firstLayer_ : (firstLayer_ + 1);
122 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with "
123 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
131 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
132 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
133 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
136 slopeB_ =
args.value<std::vector<double>>(
"SlopeBottom");
137 zFrontB_ =
args.value<std::vector<double>>(
"ZFrontBottom");
138 rMinFront_ =
args.value<std::vector<double>>(
"RMinFront");
139 slopeT_ =
args.value<std::vector<double>>(
"SlopeTop");
140 zFrontT_ =
args.value<std::vector<double>>(
"ZFrontTop");
141 rMaxFront_ =
args.value<std::vector<double>>(
"RMaxFront");
143 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
146 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
150 waferIndex_ =
args.value<std::vector<int>>(
"WaferIndex");
151 waferProperty_ =
args.value<std::vector<int>>(
"WaferProperties");
152 waferLayerStart_ =
args.value<std::vector<int>>(
"WaferLayerStart");
154 edm::LogVerbatim(
"HGCalGeom") <<
"waferProperties with " << waferIndex_.size() <<
" entries in "
155 << waferLayerStart_.size() <<
" layers";
156 for (
unsigned int k = 0;
k < waferLayerStart_.size(); ++
k)
158 for (
unsigned int k = 0;
k < waferIndex_.size(); ++
k)
170 edm::LogVerbatim(
"HGCalGeom") <<
"==>> Constructing DDHGCalSiliconModule...";
174 double zi(zMinBlock_);
176 for (
unsigned int i = 0;
i < layers_.size(); ++
i) {
177 double zo = zi + layerThick_[
i];
179 int laymax = laymin + layers_[
i];
182 for (
int ly = laymin; ly < laymax; ++ly) {
183 int ii = layerType_[ly];
184 int copy = copyNumber_[
ii];
185 double hthick = 0.5 * thick_[
ii];
188 thickTot += thick_[
ii];
192 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: Layer " << ly <<
":" <<
ii <<
" Front "
201 if (layerSense_[ly] < 1) {
202 std::vector<double> pgonZ, pgonRin, pgonRout;
203 double rmax = routF * cosAlpha_ - tol1;
216 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
218 if (layerSense_[ly] == 0 || absorbMode_ == 0)
219 pgonRout[isec] = rmax;
221 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1;
223 dd4hep::Solid solid =
dd4hep::Polyhedra(sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
228 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << solid.name() <<
" polyhedra of " << sectors_
231 <<
" sections and filled with " << matter.name();
232 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
241 dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi);
247 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << solid.name() <<
" Tubs made of " << matter.name()
250 <<
cms::convert2mm(hthick) <<
", 0.0, 360.0 and position " << glog.name()
251 <<
" number " <<
copy <<
":" << layerCenter_[
copy - firstLayer_];
253 positionSensitive(ctxt,
e, glog, layerSense_[ly], (
copy - firstLayer_));
257 mother.placeVolume(glog,
copy,
r1);
258 int inc = ((layerSense_[ly] > 0) && (facingTypes_ > 1)) ? 2 : 1;
259 copyNumber_[
ii] =
copy + inc;
263 <<
") with no rotation";
270 if (
std::abs(thickTot - layerThick_[
i]) >= tol2) {
271 if (thickTot > layerThick_[
i]) {
274 <<
": thickness of all its components **** ERROR ****";
277 <<
" does not match with " <<
cms::convert2mm(thickTot) <<
" of the components";
283 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << copies_.size() <<
" different wafer copy numbers";
285 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
289 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalSiliconModule construction...";
295 static const double sqrt3 =
std::sqrt(3.0);
296 int layercenter = layerCenter_[
layer];
297 int firstWafer = waferLayerStart_[
layer];
298 int lastWafer = ((
layer + 1 < static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[
layer + 1]
299 : static_cast<int>(waferIndex_.size()));
300 double r = 0.5 * (waferSize_ + waferSepar_);
301 double R = 2.0 *
r / sqrt3;
302 double dy = 0.75 *
R;
303 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
305 int ium(0), ivm(0), kount(0);
306 std::vector<int> ntype(3, 0);
310 <<
" WaferSize " <<
cms::convert2mm((waferSize_ + waferSepar_)) <<
" index "
311 << firstWafer <<
":" << (lastWafer - 1);
313 for (
int k = firstWafer;
k < lastWafer; ++
k) {
322 double xpos = xyoff.first + nc *
r;
323 double ypos = xyoff.second +
nr *
dy;
330 i = (layertype - 1) * waferTypes_ +
type;
331 wafer = waferFull_[
i];
333 i = (
part - 1) * waferTypes_ * facingTypes_ * orientationTypes_ +
334 (layertype - 1) * waferTypes_ * orientationTypes_ +
type * orientationTypes_ + orien;
337 <<
":" << orien <<
":" <<
i <<
":" << waferPart_.size();
339 wafer = waferPart_[
i];
344 <<
" Wafer " << wafer <<
" number " <<
copy <<
" type:part:orien:ind " <<
type
345 <<
":" <<
part <<
":" << orien <<
":" <<
i <<
" layer:u:v:indx "
346 << (
layer + firstLayer_) <<
":" << u <<
":" <<
v;
352 if (copies_.count(
copy) == 0)
353 copies_.insert(
copy);
356 glog.placeVolume(ns.
volume(wafer),
copy, tran);
359 edm::LogVerbatim(
"HGCalGeom") <<
" DDHGCalSiliconModule: " << wafer <<
" number " <<
copy <<
" type " << layertype
360 <<
":" <<
type <<
" positioned in " << glog.name() <<
" at ("
366 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: Maximum # of u " << ium <<
" # of v " << ivm <<
" and "
367 << kount <<
" wafers (" << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
") for "