CMS 3D CMS Logo

DDHGCalPassiveFull.cc
Go to the documentation of this file.
1 // File: DDHGCalPassiveFull.cc
3 // Description: Geometry factory class for a full silicon Wafer
4 // Created by Sunanda Banerjee
17 
18 #include <string>
19 #include <vector>
20 #include <sstream>
21 
22 //#define EDM_ML_DEBUG
23 
24 class DDHGCalPassiveFull : public DDAlgorithm {
25 public:
26  // Constructor and Destructor
28  ~DDHGCalPassiveFull() override = default;
29 
30  void initialize(const DDNumericArguments& nArgs,
31  const DDVectorArguments& vArgs,
32  const DDMapArguments& mArgs,
33  const DDStringArguments& sArgs,
34  const DDStringVectorArguments& vsArgs) override;
35  void execute(DDCompactView& cpv) override;
36 
37 private:
38  std::string material_; // Material name for module
39  double thick_; // Module thickness
40  double waferSize_; // Wafer size
41  double waferSepar_; // Sensor separation
42  std::vector<std::string> layerNames_; // Names of the layers
43  std::vector<std::string> materials_; // Materials of the layers
44  std::vector<double> layerThick_; // Thickness of layers
45  std::vector<int> copyNumber_; // Initial copy numbers
46  std::vector<int> layerType_; // Layer types
47 };
48 
50 #ifdef EDM_ML_DEBUG
51  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassiveFull: Creating an instance";
52 #endif
53 }
54 
56  const DDVectorArguments& vArgs,
57  const DDMapArguments&,
58  const DDStringArguments& sArgs,
59  const DDStringVectorArguments& vsArgs) {
60  material_ = sArgs["ModuleMaterial"];
61  thick_ = nArgs["ModuleThickness"];
62  waferSize_ = nArgs["WaferSize"];
63 #ifdef EDM_ML_DEBUG
64  waferSepar_ = nArgs["SensorSeparation"];
65  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassiveFull: Module " << parent().name() << " made of " << material_ << " T "
66  << thick_ << " Wafer 2r " << waferSize_ << " Half Separation " << waferSepar_;
67 #endif
68  layerNames_ = vsArgs["LayerNames"];
69  materials_ = vsArgs["LayerMaterials"];
70  layerThick_ = vArgs["LayerThickness"];
71  copyNumber_.resize(materials_.size(), 1);
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassiveFull: " << layerNames_.size() << " types of volumes";
74  for (unsigned int i = 0; i < layerNames_.size(); ++i)
75  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << layerNames_[i] << " of thickness " << layerThick_[i]
76  << " filled with " << materials_[i];
77 #endif
78  layerType_ = dbl_to_int(vArgs["LayerType"]);
79 #ifdef EDM_ML_DEBUG
80  std::ostringstream st1;
81  for (unsigned int i = 0; i < layerType_.size(); ++i)
82  st1 << " [" << i << "] " << layerType_[i];
83  edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " blocks" << st1.str();
84 #endif
85 }
86 
88 #ifdef EDM_ML_DEBUG
89  edm::LogVerbatim("HGCalGeom") << "==>> Executing DDHGCalPassiveFull...";
90 #endif
91 
92  static constexpr double tol = 0.00001;
93  static const double sqrt3 = std::sqrt(3.0);
94  double rM = 0.5 * waferSize_;
95  double RM2 = rM / sqrt3;
96 
97  // First the mother
98  std::vector<double> xM = {rM, 0, -rM, -rM, 0, rM};
99  std::vector<double> yM = {RM2, 2 * RM2, RM2, -RM2, -2 * RM2, -RM2};
100  std::vector<double> zw = {-0.5 * thick_, 0.5 * thick_};
101  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
102  std::string parentName = parent().name().name();
103  DDSolid solid = DDSolidFactory::extrudedpolygon(parentName, xM, yM, zw, zx, zy, scale);
105  DDMaterial matter(matName);
106  DDLogicalPart glogM = DDLogicalPart(solid.ddname(), matter, solid);
107 #ifdef EDM_ML_DEBUG
108  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassiveFull: " << solid.name() << " extruded polygon made of " << matName
109  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
110  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
111  << " and " << xM.size() << " edges";
112  for (unsigned int kk = 0; kk < xM.size(); ++kk)
113  edm::LogVerbatim("HGCalGeom") << "[" << kk << "] " << xM[kk] << ":" << yM[kk];
114 #endif
115 
116  // Then the layers
117  std::vector<DDLogicalPart> glogs(materials_.size());
118  double zi(-0.5 * thick_), thickTot(0.0);
119  for (unsigned int l = 0; l < layerType_.size(); l++) {
120  unsigned int i = layerType_[l];
121  if (copyNumber_[i] == 1) {
122  zw[0] = -0.5 * layerThick_[i];
123  zw[1] = 0.5 * layerThick_[i];
124  std::string layerName = parentName + layerNames_[i];
125  solid = DDSolidFactory::extrudedpolygon(layerName, xM, yM, zw, zx, zy, scale);
127  DDMaterial matter(matN);
128  glogs[i] = DDLogicalPart(solid.ddname(), matter, solid);
129 #ifdef EDM_ML_DEBUG
130  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassiveFull: Layer " << i << ":" << l << ":" << solid.name()
131  << " extruded polygon made of " << matN << " z|x|y|s (0) " << zw[0] << ":" << zx[0]
132  << ":" << zy[0] << ":" << scale[0] << " z|x|y|s (1) " << zw[1] << ":" << zx[1]
133  << ":" << zy[1] << ":" << scale[1] << " and " << xM.size() << " edges";
134  for (unsigned int kk = 0; kk < xM.size(); ++kk)
135  edm::LogVerbatim("HGCalGeom") << "[" << kk << "] " << xM[kk] << ":" << yM[kk];
136 #endif
137  }
138  DDTranslation tran0(0, 0, (zi + 0.5 * layerThick_[i]));
139  DDRotation rot;
140  cpv.position(glogs[i], glogM, copyNumber_[i], tran0, rot);
141 #ifdef EDM_ML_DEBUG
142  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassiveFull: " << glogs[i].name() << " number " << copyNumber_[i]
143  << " positioned in " << glogM.name() << " at " << tran0 << " with no rotation";
144 #endif
145  ++copyNumber_[i];
146  zi += layerThick_[i];
147  thickTot += layerThick_[i];
148  }
149  if ((std::abs(thickTot - thick_) >= tol) && (!layerType_.empty())) {
150  if (thickTot > thick_) {
151  edm::LogError("HGCalGeom") << "Thickness of the partition " << thick_ << " is smaller than " << thickTot
152  << ": thickness of all its components **** ERROR ****";
153  } else {
154  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick_ << " does not match with " << thickTot
155  << " of the components";
156  }
157  }
158 }
159 
160 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalPassiveFull, "hgcal:DDHGCalPassiveFull");
Log< level::Info, true > LogVerbatim
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::vector< double > layerThick_
Log< level::Error, false > LogError
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
std::vector< int > layerType_
T sqrt(T t)
Definition: SSEVec.h:23
std::vector< std::string > materials_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
~DDHGCalPassiveFull() override=default
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
const N & name() const
Definition: DDBase.h:59
static DDSolid extrudedpolygon(const DDName &name, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::vector< double > &zx, const std::vector< double > &zy, const std::vector< double > &zscale)
Definition: DDSolid.cc:584
const N & ddname() const
Definition: DDBase.h:61
std::vector< int > copyNumber_
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:84
#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 = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
void execute(DDCompactView &cpv) override
std::vector< std::string > layerNames_