CMS 3D CMS Logo

DDHGCalCell.cc
Go to the documentation of this file.
12 
13 #include <string>
14 #include <vector>
15 
16 //#define EDM_ML_DEBUG
17 
18 class DDHGCalCell : public DDAlgorithm {
19 public:
20  // Constructor and Destructor
21  DDHGCalCell();
22  ~DDHGCalCell() override;
23 
24  void initialize(const DDNumericArguments& nArgs,
25  const DDVectorArguments& vArgs,
26  const DDMapArguments& mArgs,
27  const DDStringArguments& sArgs,
28  const DDStringVectorArguments& vsArgs) override;
29  void execute(DDCompactView& cpv) override;
30 
31 private:
32  double waferSize_; // Wafer Size
33  double waferT_; // Wafer Thickness
34  double cellT_; // Cell Thickness
35  int nCells_; // Number of columns (8:12)
36  int posSens_; // Position depleted layer
37  std::string material_; // Name of the material
38  std::string fullCN_, fullSensN_; // Name of full cell
39  std::vector<std::string> truncCN_, truncSensN_; // Names of truncated cells
40  std::vector<std::string> extenCN_, extenSensN_; // Names of extended cells
41  std::vector<std::string> cornrCN_, cornrSensN_; // Names of corner cells
42  std::string nameSpace_; // Namespace to be used
43 };
44 
46 #ifdef EDM_ML_DEBUG
47  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Creating an instance";
48 #endif
49 }
50 
52 
54  const DDVectorArguments&,
55  const DDMapArguments&,
56  const DDStringArguments& sArgs,
57  const DDStringVectorArguments& vsArgs) {
58  waferSize_ = nArgs["WaferSize"];
59  waferT_ = nArgs["WaferThick"];
60  cellT_ = nArgs["CellThick"];
61  nCells_ = (int)(nArgs["NCells"]);
62  posSens_ = (int)(nArgs["PosSensitive"]);
63  material_ = sArgs["Material"];
64  fullCN_ = sArgs["FullCell"];
65  fullSensN_ = sArgs["FullSensitive"];
66  truncCN_ = vsArgs["TruncatedCell"];
67  truncSensN_ = vsArgs["TruncatedSensitive"];
68  extenCN_ = vsArgs["ExtendedCell"];
69  extenSensN_ = vsArgs["ExtendedSensitive"];
70  cornrCN_ = vsArgs["CornerCell"];
71  cornrSensN_ = vsArgs["CornerSensitive"];
73  if ((truncCN_.size() != truncSensN_.size()) || (extenCN_.size() != extenSensN_.size()) ||
74  (cornrCN_.size() != cornrSensN_.size()))
75  edm::LogWarning("HGCalGeom") << "The number of cells & sensitive differ:"
76  << " Truncated " << truncCN_.size() << ":" << truncSensN_.size() << " Extended "
77  << extenCN_.size() << ":" << extenSensN_.size() << " Corners " << cornrCN_.size()
78  << ":" << cornrSensN_.size();
79  if ((truncCN_.size() != 3) || (extenCN_.size() != 3) || (cornrCN_.size() != 6))
80  edm::LogWarning("HGCalGeom") << "DDHGCalCell: The number of cells does not"
81  << " match with Standard: Truncated " << truncCN_.size() << ":3 Extended "
82  << extenCN_.size() << ":3"
83  << " Corners " << cornrCN_.size() << ":6";
84 #ifdef EDM_ML_DEBUG
85  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Wafer r " << waferSize_ << " T " << waferT_ << " Cell T " << cellT_
86  << " Cells/Wafer " << nCells_ << " Material " << material_ << "Sensitive Position "
87  << posSens_ << " NameSpace " << nameSpace_ << " Full Cell: " << fullCN_ << ":"
88  << fullSensN_;
89  for (unsigned int k = 0; k < truncCN_.size(); ++k)
90  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Truncated Cell[" << k << "] " << truncCN_[k] << ":"
91  << truncSensN_[k];
92  for (unsigned int k = 0; k < extenCN_.size(); ++k)
93  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Extended Cell[" << k << "] " << extenCN_[k] << ":" << extenSensN_[k];
94  for (unsigned int k = 0; k < cornrCN_.size(); ++k)
95  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Corner Cell[" << k << "] " << cornrCN_[k] << ":" << cornrSensN_[k];
96 #endif
97 }
98 
100 #ifdef EDM_ML_DEBUG
101  edm::LogVerbatim("HGCalGeom") << "==>> Executing DDHGCalCell...";
102 #endif
103 
105  DDMaterial matter(matName);
106 #ifdef EDM_ML_DEBUG
107  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << matName << " initialized at " << &matter;
108 #endif
109  DDLogicalPart glog1, glog2;
110 
111  static const double sqrt3 = std::sqrt(3.0);
112  double R = waferSize_ / (3.0 * nCells_);
113  double r = 0.5 * R * sqrt3;
114  double dx1 = R;
115  double dx2 = 0.5 * dx1;
116  double dx3 = 2.5 * dx2;
117  double dx4 = 0.5 * dx2;
118  double dy1 = r;
119  double dy2 = 0.5 * dy1;
120  double dy3 = 1.5 * dy1;
121  std::vector<double> xx = {dx1, dx2, -dx2, -dx1, -dx2, dx2, dx3, -dx4, -dx1, -dx1, -dx4, dx3};
122  std::vector<double> yy = {0, dy1, dy1, 0, -dy1, -dy1, dy2, dy3, dy1, -dy1, -dy3, -dy2};
123  double zpos = (posSens_ == 0) ? -0.5 * (waferT_ - cellT_) : 0.5 * (waferT_ - cellT_);
124  DDTranslation tran(0, 0, zpos);
125 
126  // First the full cell
127  std::vector<double> xw = {xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]};
128  std::vector<double> yw = {yy[0], yy[1], yy[2], yy[3], yy[4], yy[5]};
129  std::vector<double> zw = {-0.5 * waferT_, 0.5 * waferT_};
130  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
131  DDSolid solid = DDSolidFactory::extrudedpolygon(DDName(fullCN_, nameSpace_), xw, yw, zw, zx, zy, scale);
132  glog1 = DDLogicalPart(solid.ddname(), matter, solid);
133 #ifdef EDM_ML_DEBUG
134  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << matName
135  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
136  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
137  << " and " << xw.size() << " edges";
138  for (unsigned int k = 0; k < xw.size(); ++k)
139  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xw[k] << ":" << yw[k];
140 #endif
141  std::vector<double> zc = {-0.5 * cellT_, 0.5 * cellT_};
142  solid = DDSolidFactory::extrudedpolygon(DDName(fullSensN_, nameSpace_), xw, yw, zc, zx, zy, scale);
143  glog2 = DDLogicalPart(solid.ddname(), matter, solid);
144 #ifdef EDM_ML_DEBUG
145  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << matName
146  << " z|x|y|s (0) " << zc[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
147  << " z|x|y|s (1) " << zc[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
148  << " and " << xw.size() << " edges";
149  for (unsigned int k = 0; k < xw.size(); ++k)
150  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xw[k] << ":" << yw[k];
151 #endif
152  DDRotation rot;
153  cpv.position(glog2, glog1, 1, tran, rot);
154 #ifdef EDM_ML_DEBUG
155  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name() << " at "
156  << tran << " with " << rot;
157 #endif
158 
159  static const int ir0[] = {0, 1, 0};
160  static const int ir1[] = {1, 2, 1};
161  static const int ir2[] = {2, 3, 3};
162  static const int ir3[] = {3, 4, 4};
163  static const int ir4[] = {5, 5, 5};
164  for (unsigned int i = 0; i < truncCN_.size(); ++i) {
165  std::vector<double> xw = {xx[ir0[i]], xx[ir1[i]], xx[ir2[i]], xx[ir3[i]], xx[ir4[i]]};
166  std::vector<double> yw = {yy[ir0[i]], yy[ir1[i]], yy[ir2[i]], yy[ir3[i]], yy[ir4[i]]};
167  solid = DDSolidFactory::extrudedpolygon(DDName(truncCN_[i], nameSpace_), xw, yw, zw, zx, zy, scale);
168  glog1 = DDLogicalPart(solid.ddname(), matter, solid);
169 #ifdef EDM_ML_DEBUG
170  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << matName
171  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
172  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
173  << " and " << xw.size() << " edges";
174  for (unsigned int k = 0; k < xw.size(); ++k)
175  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xw[k] << ":" << yw[k];
176 #endif
177  solid = DDSolidFactory::extrudedpolygon(DDName(truncSensN_[i], nameSpace_), xw, yw, zc, zx, zy, scale);
178  glog2 = DDLogicalPart(solid.ddname(), matter, solid);
179 #ifdef EDM_ML_DEBUG
180  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << matName
181  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
182  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
183  << " and " << xw.size() << " edges";
184  for (unsigned int k = 0; k < xw.size(); ++k)
185  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xw[k] << ":" << yw[k];
186 #endif
187  cpv.position(glog2, glog1, 1, tran, rot);
188 #ifdef EDM_ML_DEBUG
189  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
190  << " at " << tran << " with " << rot;
191 #endif
192  }
193 
194  static const int ie0[] = {1, 5, 0};
195  static const int ie1[] = {2, 6, 1};
196  static const int ie2[] = {3, 7, 8};
197  static const int ie3[] = {10, 3, 9};
198  static const int ie4[] = {11, 4, 5};
199  for (unsigned int i = 0; i < extenCN_.size(); ++i) {
200  std::vector<double> xw = {xx[ie0[i]], xx[ie1[i]], xx[ie2[i]], xx[ie3[i]], xx[ie4[i]]};
201  std::vector<double> yw = {yy[ie0[i]], yy[ie1[i]], yy[ie2[i]], yy[ie3[i]], yy[ie4[i]]};
202  solid = DDSolidFactory::extrudedpolygon(DDName(extenCN_[i], nameSpace_), xw, yw, zw, zx, zy, scale);
203  glog1 = DDLogicalPart(solid.ddname(), matter, solid);
204 #ifdef EDM_ML_DEBUG
205  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << matName
206  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
207  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
208  << " and " << xw.size() << " edges";
209  for (unsigned int k = 0; k < xw.size(); ++k)
210  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xw[k] << ":" << yw[k];
211 #endif
212  solid = DDSolidFactory::extrudedpolygon(DDName(extenSensN_[i], nameSpace_), xw, yw, zc, zx, zy, scale);
213  glog2 = DDLogicalPart(solid.ddname(), matter, solid);
214 #ifdef EDM_ML_DEBUG
215  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << matName
216  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
217  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
218  << " and " << xw.size() << " edges";
219  for (unsigned int k = 0; k < xw.size(); ++k)
220  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xw[k] << ":" << yw[k];
221 #endif
222  cpv.position(glog2, glog1, 1, tran, rot);
223 #ifdef EDM_ML_DEBUG
224  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
225  << " at " << tran << " with " << rot;
226 #endif
227  }
228 
229  static const int ic0[] = {0, 1, 1, 1, 1, 0};
230  static const int ic1[] = {1, 2, 2, 7, 3, 1};
231  static const int ic2[] = {8, 3, 3, 3, 4, 3};
232  static const int ic3[] = {3, 5, 10, 4, 5, 9};
233  static const int ic4[] = {5, 11, 5, 5, 6, 5};
234  for (unsigned int i = 0; i < cornrCN_.size(); ++i) {
235  std::vector<double> xw = {xx[ic0[i]], xx[ic1[i]], xx[ic2[i]], xx[ic3[i]], xx[ic4[i]]};
236  std::vector<double> yw = {yy[ic0[i]], yy[ic1[i]], yy[ic2[i]], yy[ic3[i]], yy[ic4[i]]};
237  solid = DDSolidFactory::extrudedpolygon(DDName(cornrCN_[i], nameSpace_), xw, yw, zw, zx, zy, scale);
238  glog1 = DDLogicalPart(solid.ddname(), matter, solid);
239 #ifdef EDM_ML_DEBUG
240  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << matName
241  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
242  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
243  << " and " << xw.size() << " edges";
244  for (unsigned int k = 0; k < xw.size(); ++k)
245  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xw[k] << ":" << yw[k];
246 #endif
247  solid = DDSolidFactory::extrudedpolygon(DDName(cornrSensN_[i], nameSpace_), xw, yw, zc, zx, zy, scale);
248  glog2 = DDLogicalPart(solid.ddname(), matter, solid);
249 #ifdef EDM_ML_DEBUG
250  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << matName
251  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
252  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
253  << " and " << xw.size() << " edges";
254  for (unsigned int k = 0; k < xw.size(); ++k)
255  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xw[k] << ":" << yw[k];
256 #endif
257  cpv.position(glog2, glog1, 1, tran, rot);
258 #ifdef EDM_ML_DEBUG
259  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
260  << " at " << tran << " with " << rot;
261 #endif
262  }
263 }
264 
265 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalCell, "hgcal:DDHGCalCell");
const N & name() const
Definition: DDBase.h:59
std::string fullSensN_
Definition: DDHGCalCell.cc:38
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
Definition: DDHGCalCell.cc:53
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
~DDHGCalCell() override
Definition: DDHGCalCell.cc:51
static std::string & ns()
std::vector< std::string > truncCN_
Definition: DDHGCalCell.cc:39
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
std::vector< std::string > extenSensN_
Definition: DDHGCalCell.cc:40
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
void execute(DDCompactView &cpv) override
Definition: DDHGCalCell.cc:99
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
std::string nameSpace_
Definition: DDHGCalCell.cc:42
double cellT_
Definition: DDHGCalCell.cc:34
T sqrt(T t)
Definition: SSEVec.h:19
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
double waferSize_
Definition: DDHGCalCell.cc:32
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:570
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
double waferT_
Definition: DDHGCalCell.cc:33
std::vector< std::string > cornrCN_
Definition: DDHGCalCell.cc:41
std::vector< std::string > truncSensN_
Definition: DDHGCalCell.cc:39
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:75
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::string material_
Definition: DDHGCalCell.cc:37
std::vector< std::string > extenCN_
Definition: DDHGCalCell.cc:40
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
std::string fullCN_
Definition: DDHGCalCell.cc:38
std::vector< std::string > cornrSensN_
Definition: DDHGCalCell.cc:41
const N & ddname() const
Definition: DDBase.h:61