13 #include <unordered_set> 16 #include "DD4hep/DetFactoryHelper.h" 73 wafers_ =
args.value<std::vector<std::string>>(
"WaferNames");
75 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << wafers_.size() <<
" wafers";
76 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
80 materials_ =
args.value<std::vector<std::string>>(
"MaterialNames");
81 names_ =
args.value<std::vector<std::string>>(
"VolumeNames");
82 thick_ =
args.value<std::vector<double>>(
"Thickness");
83 copyNumber_.resize(materials_.size(), 1);
85 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << materials_.size() <<
" types of volumes";
86 for (
unsigned int i = 0;
i < names_.size(); ++
i)
87 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " 89 <<
" first copy number " << copyNumber_[
i];
92 layers_ =
args.value<std::vector<int>>(
"Layers");
93 layerThick_ =
args.value<std::vector<double>>(
"LayerThick");
95 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
96 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
98 <<
" with " << layers_[
i] <<
" layers";
101 layerType_ =
args.value<std::vector<int>>(
"LayerType");
102 layerSense_ =
args.value<std::vector<int>>(
"LayerSense");
103 firstLayer_ =
args.value<
int>(
"FirstLayer");
104 absorbMode_ =
args.value<
int>(
"AbsorberMode");
105 sensitiveMode_ =
args.value<
int>(
"SensitiveMode");
108 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
110 layerCenter_ =
args.value<std::vector<int>>(
"LayerCenter");
112 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
115 if (firstLayer_ > 0) {
116 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
117 if (layerSense_[
i] > 0) {
118 int ii = layerType_[
i];
119 copyNumber_[
ii] = firstLayer_;
121 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with " 122 << 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 zMinBlock_ =
args.value<
double>(
"zMinBlock");
138 rad100to200_ =
args.value<std::vector<double>>(
"rad100to200");
139 rad200to300_ =
args.value<std::vector<double>>(
"rad200to300");
140 zMinRadPar_ =
args.value<
double>(
"zMinForRadPar");
141 choiceType_ =
args.value<
int>(
"choiceType");
142 nCutRadPar_ =
args.value<
int>(
"nCornerCut");
143 fracAreaMin_ =
args.value<
double>(
"fracAreaMin");
144 waferSize_ =
args.value<
double>(
"waferSize");
145 waferSepar_ =
args.value<
double>(
"SensorSeparation");
146 sectors_ =
args.value<
int>(
"Sectors");
147 alpha_ = (1._pi) / sectors_;
148 cosAlpha_ =
cos(alpha_);
151 <<
" radius for wafer type separation uses " << rad100to200_.size()
152 <<
" parameters; zmin " <<
cms::convert2mm(zMinRadPar_) <<
" cutoff " << choiceType_
153 <<
":" << nCutRadPar_ <<
":" << fracAreaMin_ <<
" wafer width " 155 <<
" sectors " << sectors_ <<
":" <<
convertRadToDeg(alpha_) <<
":" << cosAlpha_;
156 for (
unsigned int k = 0;
k < rad100to200_.size(); ++
k)
157 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] 100-200 " << rad100to200_[
k] <<
" 200-300 " << rad200to300_[
k];
160 slopeB_ =
args.value<std::vector<double>>(
"SlopeBottom");
161 zFrontB_ =
args.value<std::vector<double>>(
"ZFrontBottom");
162 rMinFront_ =
args.value<std::vector<double>>(
"RMinFront");
163 slopeT_ =
args.value<std::vector<double>>(
"SlopeTop");
164 zFrontT_ =
args.value<std::vector<double>>(
"ZFrontTop");
165 rMaxFront_ =
args.value<std::vector<double>>(
"RMaxFront");
167 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
170 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
179 waferType_ = std::make_unique<HGCalWaferType>(rad100to200_,
187 ConstructAlgo(ctxt,
e);
196 ConstructLayers(par, ctxt,
e);
198 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << copies_.size() <<
" different wafer copy numbers";
200 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
204 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalEEAlgo construction...";
209 static constexpr
double tol1 = 0.01 * dd4hep::mm;
210 static constexpr
double tol2 = 0.00001 * dd4hep::mm;
217 double zi(zMinBlock_);
219 for (
unsigned int i = 0;
i < layers_.size();
i++) {
220 double zo = zi + layerThick_[
i];
222 int laymax = laymin + layers_[
i];
225 for (
int ly = laymin; ly < laymax; ++ly) {
226 int ii = layerType_[ly];
227 int copy = copyNumber_[
ii];
228 double hthick = 0.5 * thick_[
ii];
231 thickTot += thick_[
ii];
244 if (layerSense_[ly] < 1) {
245 std::vector<double> pgonZ, pgonRin, pgonRout;
246 if (layerSense_[ly] == 0 || absorbMode_ == 0) {
247 double rmax = routF * cosAlpha_ - tol1;
248 pgonZ.emplace_back(-hthick);
249 pgonZ.emplace_back(hthick);
250 pgonRin.emplace_back(rinB);
251 pgonRin.emplace_back(rinB);
252 pgonRout.emplace_back(rmax);
253 pgonRout.emplace_back(rmax);
270 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec)
274 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
276 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1;
280 dd4hep::Solid solid =
dd4hep::Polyhedra(sectors_, -alpha_, 2._pi, pgonZ, pgonRin, pgonRout);
286 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << solid.name() <<
" polyhedra of " << sectors_
289 <<
" sections and filled with " << matName;
291 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
300 dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi);
306 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << solid.name() <<
" Tubs made of " << matter.name()
309 <<
cms::convert2mm(hthick) <<
", 0.0, 360.0 and position " << glog.name()
310 <<
" number " <<
copy <<
":" << layerCenter_[
copy - firstLayer_];
313 ctxt,
e, glog, rins, routs,
zz, layerSense_[ly], layerCenter_[
copy - firstLayer_]);
317 mother_.placeVolume(glog,
copy, r1);
321 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEAlgo: " << glog.name() <<
" number " <<
copy <<
" positioned in " 328 if (
std::abs(thickTot - layerThick_[
i]) >= tol2) {
329 if (thickTot > layerThick_[
i]) {
332 <<
": thickness of all its components **** ERROR ****";
335 <<
" does not match with " <<
cms::convert2mm(thickTot) <<
" of the components";
351 static const double sqrt3 =
std::sqrt(3.0);
352 double r = 0.5 * (waferSize_ + waferSepar_);
353 double R = 2.0 * r / sqrt3;
354 double dy = 0.75 *
R;
355 int N = (
int)(0.5 * rout / r) + 2;
356 const auto& xyoff = geomTools_.
shiftXY(layercenter, (waferSize_ + waferSepar_));
358 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0),
ntot(0), nin(0);
359 std::vector<int> ntype(6, 0);
367 for (
int u = -
N; u <=
N; ++u) {
368 for (
int v = -
N;
v <=
N; ++
v) {
371 double xpos = xyoff.first + nc * r;
372 double ypos = xyoff.second +
nr *
dy;
381 << layertype <<
" u " << u <<
" v " <<
v <<
" with " <<
corner.first
394 if (copies_.count(
copy) == 0)
395 copies_.insert(
copy);
413 <<
" DDHGCalEEAlgo: " << wafers_[
type] <<
" number " <<
copy <<
" positioned in " << glog.name()
422 edm::LogVerbatim(
"HGCalGeom") <<
" DDHGCalEEAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
423 <<
":" << ivmAll <<
" and " << nin <<
":" << kount <<
":" <<
ntot <<
" wafers (" 424 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":" 425 << ntype[4] <<
":" << ntype[5] <<
") for " << glog.name() <<
" R " std::vector< int > layerSense_
Log< level::Info, true > LogVerbatim
HGCalEEAlgo(cms::DDParsingContext &ctxt, xml_h e)
HGCalGeomTools geomTools_
std::vector< double > rMaxFront_
constexpr NumType convertRadToDeg(NumType radians)
constexpr NumType convert2mm(NumType length)
std::vector< double > slopeB_
std::string to_string(const V &value)
std::vector< int > layerCenter_
Log< level::Error, false > LogError
dd4hep::Material material(const std::string &name) const
std::vector< double > rMinFront_
std::unique_ptr< HGCalWaferType > waferType_
static constexpr uint32_t k_CornerSize
#define DECLARE_DDCMS_DETELEMENT(name, func)
void ConstructLayers(const dd4hep::Volume module, cms::DDParsingContext &ctxt, xml_h e)
static constexpr long s_executed
std::unordered_set< int > copies_
std::vector< int > layerType_
std::string_view name() const
Cos< T >::type cos(const T &t)
std::vector< std::string > materials_
Abs< T >::type abs(const T &t)
void PositionSensitive(cms::DDParsingContext &ctxt, xml_h e, const dd4hep::Volume &glog, double rin, double rout, double zpos, int layertype, int layercenter)
std::vector< std::string > names_
std::vector< double > thick_
std::vector< double > rad200to300_
std::vector< double > zFrontT_
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
std::vector< int > layers_
void ConstructAlgo(cms::DDParsingContext &ctxt, xml_h e)
std::vector< double > rad100to200_
std::vector< double > layerThick_
std::vector< double > slopeT_
static int32_t packTypeUV(int type, int u, int v)
std::vector< double > zFrontB_
Log< level::Warning, false > LogWarning
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
std::vector< std::string > wafers_
std::vector< int > copyNumber_
dd4hep::Volume volume(const std::string &name, bool exc=true) const
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
std::string prepend(const std::string &) const