10 #include <unordered_set>
30 using namespace angle_units::operators;
46 double rMax(
double z);
50 static constexpr
double tol_ = 0.00001;
84 wafer_ = vsArgs[
"WaferName"];
86 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << wafer_.size() <<
" wafers";
87 for (
unsigned int i = 0;
i < wafer_.size(); ++
i)
90 materials_ = vsArgs[
"MaterialNames"];
91 names_ = vsArgs[
"VolumeNames"];
92 thick_ = vArgs[
"Thickness"];
93 copyNumber_.resize(materials_.size(), 1);
95 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << 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 " << thick_[
i]
98 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
101 layerThick_ = vArgs[
"LayerThick"];
103 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << layers_.size() <<
" blocks";
104 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
105 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" with " << layers_[
i]
109 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
111 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << layerType_.size() <<
" layers";
112 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
113 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
116 zMinBlock_ = nArgs[
"zMinBlock"];
117 rMaxFine_ = nArgs[
"rMaxFine"];
118 waferW_ = nArgs[
"waferW"];
119 sectors_ = (int)(nArgs[
"Sectors"]);
121 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: zStart " << zMinBlock_ <<
" rFineCoarse " << rMaxFine_
122 <<
" wafer width " << waferW_ <<
" sectors " << sectors_;
124 slopeB_ = vArgs[
"SlopeBottom"];
125 slopeT_ = vArgs[
"SlopeTop"];
126 zFront_ = vArgs[
"ZFront"];
127 rMaxFront_ = vArgs[
"RMaxFront"];
129 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: Bottom slopes " << slopeB_[0] <<
":" << slopeB_[1] <<
" and "
130 << slopeT_.size() <<
" slopes for top";
131 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
132 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFront_[
i] <<
" Rmax " << rMaxFront_[
i] <<
" Slope "
137 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: NameSpace " << idNameSpace_;
152 edm::LogVerbatim(
"HGCalGeom") << copies_.size() <<
" different wafer copy numbers";
154 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k)
159 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalModule construction ...";
167 double zi(zMinBlock_);
169 const double tol(0.01);
170 for (
unsigned int i = 0;
i < layers_.size();
i++) {
171 double zo = zi + layerThick_[
i];
172 double routF = rMax(zi);
173 int laymax = laymin + layers_[
i];
176 for (
int ly = laymin; ly < laymax; ++ly) {
177 int ii = layerType_[ly];
178 int copy = copyNumber_[
ii];
179 double rinB = (layerSense_[ly] == 0) ? (zo * slopeB_[0]) : (zo * slopeB_[1]);
180 zz += (0.5 * thick_[
ii]);
181 thickTot += thick_[
ii];
185 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: Layer " << ly <<
":" << ii <<
" Front " << zi <<
", " << routF
186 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick_[
i];
191 if (layerSense_[ly] == 0) {
192 double alpha = 1._pi / sectors_;
193 double rmax = routF *
cos(alpha) - tol;
194 std::vector<double> pgonZ, pgonRin, pgonRout;
195 pgonZ.emplace_back(-0.5 * thick_[ii]);
196 pgonZ.emplace_back(0.5 * thick_[ii]);
197 pgonRin.emplace_back(rinB);
198 pgonRin.emplace_back(rinB);
199 pgonRout.emplace_back(rmax);
200 pgonRout.emplace_back(rmax);
205 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << solid.
name() <<
" polyhedra of " << sectors_
207 << (360.0 +
convertRadToDeg(-alpha)) <<
" with " << pgonZ.size() <<
" sections";
208 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
209 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
215 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << solid.
name() <<
" Tubs made of " << matName
216 <<
" of dimensions " << rinB <<
", " << routF <<
", " << 0.5 * thick_[
ii]
220 positionSensitive(glog, rinB, routF, cpv);
224 cpv.
position(glog, module, copy, r1, rot);
227 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << glog.
name() <<
" number " << copy <<
" positioned in "
228 << module.
name() <<
" at " << r1 <<
" with " <<
rot;
230 zz += (0.5 * thick_[
ii]);
234 if (fabs(thickTot - layerThick_[
i]) > tol_) {
235 if (thickTot > layerThick_[i]) {
236 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than thickness "
237 << thickTot <<
" of all its components **** ERROR ****\n";
239 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with "
240 << thickTot <<
" of the components\n";
251 for (
unsigned int k = 0;
k < slopeT_.size(); ++
k) {
254 r = rMaxFront_[
k] + (z - zFront_[
k]) * slopeT_[k];
266 double dx = 0.5 * waferW_;
267 double dy = 3.0 * dx *
tan(30._deg);
268 double rr = 2.0 * dx *
tan(30._deg);
269 int ncol = (int)(2.0 * rout / waferW_) + 1;
270 int nrow = (int)(rout / (waferW_ *
tan(30._deg))) + 1;
271 int incm(0), inrm(0), kount(0),
ntot(0),
nin(0), nfine(0), ncoarse(0);
273 edm::LogVerbatim(
"HGCalGeom") << glog.
ddname() <<
" rout " << rout <<
" Row " << nrow <<
" Column " << ncol;
275 for (
int nr = -nrow; nr <= nrow; ++nr) {
276 int inr = (nr >= 0) ? nr : -nr;
277 for (
int nc = -ncol; nc <= ncol; ++nc) {
278 int inc = (nc >= 0) ? nc : -nc;
279 if (inr % 2 == inc % 2) {
280 double xpos = nc *
dx;
281 double ypos = nr *
dy;
284 if (corner.first > 0) {
291 if (copies_.count(copy) == 0)
292 copies_.insert(copy);
294 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
301 if (rpos < rMaxFine_)
306 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << name <<
" number " << copy <<
" positioned in "
315 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: # of columns " << incm <<
" # of rows " << inrm <<
" and " <<
nin
316 <<
":" << kount <<
":" <<
ntot <<
" wafers (" << nfine <<
":" << ncoarse <<
") for "
317 << glog.
ddname() <<
" R " << rin <<
":" << rout;
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
std::vector< std::string > names_
std::vector< double > slopeT_
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string ©no, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
std::vector< std::string > materials_
DDMaterial is used to define and access material information.
constexpr NumType convertRadToDeg(NumType radians)
DDName is used to identify DDD entities uniquely.
std::string to_string(const V &value)
static std::string & ns()
Log< level::Error, false > LogError
Compact representation of the geometrical detector hierarchy.
std::vector< int > copyNumber_
std::vector< double > zFront_
std::unordered_set< int > copies_
A DDSolid represents the shape of a part.
static constexpr uint32_t k_CornerSize
Represents a uniquely identifyable rotation matrix.
U second(std::pair< T, U > const &p)
std::vector< std::string > wafer_
std::vector< int > layerSense_
std::vector< int > layerType_
std::vector< double > slopeB_
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
std::vector< double > thick_
void constructLayers(const cms::DDNamespace &ns, const std::vector< std::string > &wafers, const std::vector< std::string > &covers, const std::vector< int > &layerType, const std::vector< int > &layerSense, const std::vector< int > &maxModule, const std::vector< std::string > &names, const std::vector< std::string > &materials, std::vector< int > ©Number, const std::vector< double > &layerThick, const double &absorbW, const double &absorbH, const double &waferTot, const double &rMax, const double &rMaxFine, std::unordered_set< int > &copies, int firstLayer, int lastLayer, double zFront, double totalWidth, bool ignoreCenter, dd4hep::Volume &module)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
void execute(DDCompactView &cpv) override
std::vector< int > layers_
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
std::vector< double > rMaxFront_
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
void positionSensitive(DDLogicalPart &glog, double rin, double rout, DDCompactView &cpv)
static int32_t packTypeUV(int type, int u, int v)
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
#define DEFINE_EDM_PLUGIN(factory, type, name)
Log< level::Warning, false > LogWarning
std::vector< double > layerThick_
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
static DDSolid polyhedra(const DDName &name, int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polyhedra (refere to Geant3 or Geant4 documentation)