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