4 #include <unordered_set>
22 using namespace angle_units::operators;
47 void positionSensitive(
double zpos,
59 static constexpr
double tolerance_ = 0.00001;
104 wafer_ = vsArgs[
"WaferName"];
106 genMat_ = sArgs[
"GeneralMaterial"];
110 for (
auto wafer :
wafer_) {
122 names_ = vsArgs[
"VolumeNames"];
128 for (
unsigned int i = 0; i <
names_.size(); ++
i)
157 for (
unsigned int i = 0; i <
layerType_.size(); ++
i)
167 rMax_ = nArgs[
"rMax"];
171 <<
" wafer width " <<
waferW_ <<
" gap among wafers " <<
waferGap_ <<
" absorber width "
177 <<
parent().name().name();
196 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalTBModuleX construction";
209 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: Block " <<
i <<
":" << name <<
" z " << zi <<
":" << zo <<
" R "
210 <<
rMaxB_ <<
" T " << blockThick_[
i];
216 double zz = zi + 0.5 * blockThick_[
i];
219 cpv.
position(glog, parent, i, r1, rot);
221 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog.
name() <<
" number " << i <<
" positioned in "
222 << parent.
name() <<
" at " << r1 <<
" with " <<
rot;
244 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: \t\tInside Block " << block <<
" Layers " << firstLayer <<
":"
245 << lastLayer <<
" zFront " << zFront <<
" thickness " << totalWidth <<
" ignore Center "
248 double zi(zFront), thickTot(0);
249 for (
int ly = firstLayer; ly <= lastLayer; ++ly) {
254 thickTot += layerThick_[
ii];
258 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << name <<
" Layer " << ly <<
":" << ii <<
" Z " << zi <<
":"
259 << zo <<
" Thick " << layerThick_[
ii] <<
" Sense " <<
layerSense_[ly];
264 if (layerSense_[ly] == 0) {
273 cpv.
position(glog, module, copy, r1, rot);
275 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog.
name() <<
" number " << copy <<
" positioned in "
276 << module.
name() <<
" at " << r1 <<
" with " <<
rot;
278 }
else if (layerSense_[ly] > 0) {
285 if (fabs(thickTot - totalWidth) <
tolerance_) {
286 }
else if (thickTot > totalWidth) {
287 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << totalWidth <<
" is smaller than " << thickTot
288 <<
": total thickness of all its components in " << module.
name() <<
" Layers "
289 << firstLayer <<
":" << lastLayer <<
":" << ignoreCenter <<
"**** ERROR ****";
290 }
else if (thickTot < totalWidth) {
291 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << totalWidth <<
" does not match with " << thickTot
292 <<
" of the components in " << module.
name() <<
" Layers " << firstLayer <<
":"
293 << lastLayer <<
":" << ignoreCenter;
308 double dx = 0.5 * ww;
311 int ncol = (int)(2.0 * rout / ww) + 1;
312 int nrow = (int)(rout / (ww * tan30deg_)) + 1;
314 int incm(0), inrm(0);
315 edm::LogVerbatim(
"HGCalGeom") << glog.
ddname() <<
" Copy " << copyIn <<
" Type " << type <<
" rout " << rout
316 <<
" Row " << nrow <<
" column " << ncol <<
" ncrMax " << ncrMax <<
" Z " << zpos
317 <<
" Center " << ignoreCenter <<
" name " << nameIn <<
" matter " << matter.
name();
324 for (
int nr = -nrow; nr <= nrow; ++nr) {
326 for (
int nc = -ncol; nc <= ncol; ++nc) {
328 if ((inr % 2 == inc % 2) && (!ignoreCenter || nc != 0 || nr != 0)) {
329 double xpos = nc *
dx;
330 double ypos = nr *
dy;
333 yc[0] = ypos - 0.5 *
rr;
335 yc[1] = ypos + 0.5 *
rr;
339 yc[3] = ypos + 0.5 *
rr;
341 yc[4] = ypos - 0.5 *
rr;
344 bool cornerAll(
true);
345 for (
int k = 0;
k < 6; ++
k) {
351 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
358 std::string name0 = nameIn +
"M" + std::to_string(copy);
363 <<
"DDHGCalTBModuleX: " << glog1.
ddname() <<
" number " << copyIn <<
" positioned in " << glog.
ddname()
364 <<
" at " << tran <<
" with " <<
rotation;
371 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << name <<
" number " << copy <<
" positioned in "
374 if (
copies_.count(copy) == 0 && type == 1)
378 copy += copyIn * 1000000;
381 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << name <<
" number " << copy <<
" positioned in "
397 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: # of columns " << incm <<
" # of rows " << inrm <<
" and "
398 << kount <<
" wafers for " << glog.
ddname();
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
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 > wafer_
std::vector< int > layerFrontOut_
DDMaterial is used to define and access material information.
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< std::string > names_
std::vector< std::string > materials_
DDName is used to identify DDD entities uniquely.
std::vector< int > layerFrontIn_
static std::string & ns()
std::unordered_set< int > copies_
std::vector< int > layerBackIn_
void constructLayers(int block, int layerFront, int layerBack, double zFront, double thick, bool ignore, const DDLogicalPart &, DDCompactView &)
Log< level::Error, false > LogError
Compact representation of the geometrical detector hierarchy.
A DDSolid represents the shape of a part.
Represents a uniquely identifyable rotation matrix.
U second(std::pair< T, U > const &p)
void constructBlocks(const DDLogicalPart &, DDCompactView &cpv)
std::vector< double > blockThick_
std::vector< int > layerType_
std::vector< std::string > covers_
std::vector< int > layerSense_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
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)
std::vector< int > copyNumber_
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
void execute(DDCompactView &cpv) override
std::vector< int > layerBackOut_
~DDHGCalTBModuleX() override
void positionSensitive(double zpos, int copyIn, int type, double rmax, int ncrMax, bool ignoreCenter, const std::string &, const DDMaterial &, const DDLogicalPart &, DDCompactView &cpv)
static int32_t packTypeUV(int type, int u, int v)
std::vector< int > maxModule_
#define DEFINE_EDM_PLUGIN(factory, type, name)
Log< level::Warning, false > LogWarning
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
const std::string & name() const
Returns the name.
std::vector< double > layerThick_
static constexpr double tolerance_