30 #include <unordered_set> 54 static constexpr
double tol1_ = 0.01;
55 static constexpr
double tol2_ = 0.00001;
96 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: Creating an instance";
105 waferTypes_ =
static_cast<int>(nArgs[
"WaferTypes"]);
106 facingTypes_ =
static_cast<int>(nArgs[
"FacingTypes"]);
107 partialTypes_ =
static_cast<int>(nArgs[
"PartialTypes"]);
108 orientationTypes_ =
static_cast<int>(nArgs[
"OrientationTypes"]);
110 edm::LogVerbatim(
"HGCalGeom") <<
"Number of types of wafers: " << waferTypes_ <<
" facings: " << facingTypes_
111 <<
" partials: " << partialTypes_ <<
" Orientations: " << orientationTypes_;
113 firstLayer_ =
static_cast<int>(nArgs[
"FirstLayer"]);
114 absorbMode_ =
static_cast<int>(nArgs[
"AbsorberMode"]);
115 sensitiveMode_ =
static_cast<int>(nArgs[
"SensitiveMode"]);
118 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
120 zMinBlock_ = nArgs[
"zMinBlock"];
121 waferSize_ = nArgs[
"waferSize"];
122 waferSepar_ = nArgs[
"SensorSeparation"];
123 sectors_ = (
int)(nArgs[
"Sectors"]);
124 alpha_ = (1._pi) / sectors_;
125 cosAlpha_ =
cos(alpha_);
126 rotstr_ = sArgs[
"LayerRotation"];
128 edm::LogVerbatim(
"HGCalGeom") <<
"zStart " << zMinBlock_ <<
" wafer width " << waferSize_ <<
" separations " 129 << waferSepar_ <<
" sectors " << sectors_ <<
":" <<
convertRadToDeg(alpha_) <<
":" 130 << cosAlpha_ <<
" rotation matrix " << rotstr_;
132 waferFull_ = vsArgs[
"WaferNamesFull"];
133 waferPart_ = vsArgs[
"WaferNamesPartial"];
135 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << waferFull_.size() <<
" full and " << waferPart_.size()
136 <<
" partial modules\nDDHGCalSiliconModule:Full Modules:";
137 unsigned int i1max =
static_cast<unsigned int>(waferFull_.size());
138 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
139 std::ostringstream st1;
141 for (
unsigned int i =
i1;
i <
i2; ++
i)
142 st1 <<
" [" <<
i <<
"] " << waferFull_[
i];
146 i1max =
static_cast<unsigned int>(waferPart_.size());
147 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
148 std::ostringstream st1;
150 for (
unsigned int i =
i1;
i <
i2; ++
i)
151 st1 <<
" [" <<
i <<
"] " << waferPart_[
i];
155 materials_ = vsArgs[
"MaterialNames"];
156 names_ = vsArgs[
"VolumeNames"];
157 thick_ = vArgs[
"Thickness"];
158 copyNumber_.resize(materials_.size(), 1);
160 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << materials_.size() <<
" types of volumes";
161 for (
unsigned int i = 0;
i < names_.size(); ++
i)
162 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
163 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
166 layerThick_ = vArgs[
"LayerThick"];
168 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
169 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
170 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" with " << layers_[
i]
174 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
175 layerOrient_ =
dbl_to_int(vArgs[
"LayerTypes"]);
176 for (
unsigned int k = 0;
k < layerOrient_.size(); ++
k)
179 for (
unsigned int i = 0;
i < layerOrient_.size(); ++
i)
182 if (firstLayer_ > 0) {
183 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
184 if (layerSense_[
i] > 0) {
185 int ii = layerType_[
i];
186 copyNumber_[
ii] = (layerSense_[
i] == 1) ? firstLayer_ : (firstLayer_ + 1);
188 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with " 189 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
197 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
198 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
199 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class " 202 slopeB_ = vArgs[
"SlopeBottom"];
203 zFrontB_ = vArgs[
"ZFrontBottom"];
204 rMinFront_ = vArgs[
"RMinFront"];
205 slopeT_ = vArgs[
"SlopeTop"];
206 zFrontT_ = vArgs[
"ZFrontTop"];
207 rMaxFront_ = vArgs[
"RMaxFront"];
209 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
210 edm::LogVerbatim(
"HGCalGeom") <<
"Bottom Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
211 <<
" Slope " << slopeB_[
i];
212 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
213 edm::LogVerbatim(
"HGCalGeom") <<
"Top Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
214 <<
" Slope " << slopeT_[
i];
216 waferIndex_ =
dbl_to_int(vArgs[
"WaferIndex"]);
217 waferProperty_ =
dbl_to_int(vArgs[
"WaferProperties"]);
218 waferLayerStart_ =
dbl_to_int(vArgs[
"WaferLayerStart"]);
220 edm::LogVerbatim(
"HGCalGeom") <<
"waferProperties with " << waferIndex_.size() <<
" entries in " 221 << waferLayerStart_.size() <<
" layers";
222 for (
unsigned int k = 0;
k < waferLayerStart_.size(); ++
k)
224 for (
unsigned int k = 0;
k < waferIndex_.size(); ++
k)
235 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: NameSpace " << nameSpace_ <<
":";
245 edm::LogVerbatim(
"HGCalGeom") <<
"==>> Constructing DDHGCalSiliconModule...";
250 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << copies_.size() <<
" different wafer copy numbers";
252 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
256 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalSiliconModule construction...";
261 double zi(zMinBlock_);
263 for (
unsigned int i = 0;
i < layers_.size();
i++) {
264 double zo = zi + layerThick_[
i];
266 int laymax = laymin + layers_[
i];
269 for (
int ly = laymin; ly < laymax; ++ly) {
270 int ii = layerType_[ly];
271 int copy = copyNumber_[
ii];
272 double hthick = 0.5 * thick_[
ii];
275 thickTot += thick_[
ii];
279 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " 280 << routF <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " 286 if (layerSense_[ly] < 1) {
287 std::vector<double> pgonZ, pgonRin, pgonRout;
288 double rmax = routF * cosAlpha_ - tol1_;
301 for (
unsigned int isec = 0;
isec < pgonZ.size(); ++
isec) {
303 if (layerSense_[ly] == 0 || absorbMode_ == 0)
304 pgonRout[
isec] = rmax;
306 pgonRout[
isec] = pgonRout[
isec] * cosAlpha_ - tol1_;
312 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << solid.
name() <<
" polyhedra of " << sectors_
315 <<
" sections and filled with " << matName;
316 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
317 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
327 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << solid.
name() <<
" Tubs made of " << matName
328 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
329 <<
", " << hthick <<
", 0.0, 360.0 and position " << glog.
name() <<
" number " 330 <<
copy <<
":" << layerOrient_[
copy - firstLayer_];
332 positionSensitive(glog, (
copy - firstLayer_), cpv);
346 int inc = ((layerSense_[ly] > 0) && (facingTypes_ > 1)) ? 2 : 1;
347 copyNumber_[
ii] =
copy + inc;
350 <<
" positioned in " <<
module.name() <<
" at " << r1 <<
" with " <<
rotName 358 if (
std::abs(thickTot - layerThick_[
i]) >= tol2_) {
359 if (thickTot > layerThick_[
i]) {
360 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
361 <<
": thickness of all its components **** ERROR ****";
363 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with " 364 << thickTot <<
" of the components";
371 static const double sqrt3 =
std::sqrt(3.0);
372 int layercenter = layerOrient_[layer];
374 int firstWafer = waferLayerStart_[layer];
375 int lastWafer = ((layer + 1 <
static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[layer + 1]
376 :
static_cast<int>(waferIndex_.size()));
377 double r = 0.5 * (waferSize_ + waferSepar_);
378 double R = 2.0 * r / sqrt3;
379 double dy = 0.75 *
R;
380 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
382 int ium(0), ivm(0), kount(0);
383 std::vector<int> ntype(3, 0);
384 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: " << glog.
ddname() <<
" r " << r <<
" R " <<
R <<
" dy " 385 <<
dy <<
" Shift " << xyoff.first <<
":" << xyoff.second <<
" WaferSize " 386 << (waferSize_ + waferSepar_) <<
" index " << firstWafer <<
":" << (lastWafer - 1);
388 for (
int k = firstWafer;
k < lastWafer; ++
k) {
397 double xpos = xyoff.first + nc * r;
398 double ypos = xyoff.second +
nr *
dy;
405 i = layertype * waferTypes_ +
type;
406 wafer = waferFull_[
i];
408 i = (
part - 1) * waferTypes_ * facingTypes_ * orientationTypes_ + layertype * waferTypes_ * orientationTypes_ +
409 type * orientationTypes_ + orien;
412 <<
":" << orien <<
":" <<
i <<
":" << waferPart_.size();
414 wafer = waferPart_[
i];
419 <<
" Wafer " << wafer <<
" number " <<
copy <<
" type:part:orien:ind " <<
type <<
":" 420 <<
part <<
":" << orien <<
":" <<
i <<
" layer:u:v:indx " << (layer + firstLayer_)
421 <<
":" << u <<
":" <<
v;
427 if (copies_.count(
copy) == 0)
428 copies_.insert(
copy);
437 <<
":" <<
type <<
" positioned in " << glog.
ddname() <<
" at " << tran
438 <<
" with no rotation";
442 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconModule: Maximum # of u " << ium <<
" # of v " << ivm <<
" and " 443 << kount <<
" wafers (" << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
") for " std::vector< double > rMaxFront_
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
std::vector< double > zFrontT_
std::vector< int > layerSense_
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string ©no, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
void positionSensitive(const DDLogicalPart &glog, int layer, DDCompactView &cpv)
DDMaterial is used to define and access material information.
int32_t waferU(const int32_t index)
int32_t waferLayer(const int32_t index)
constexpr NumType convertRadToDeg(NumType radians)
std::vector< std::string > materials_
std::vector< double > slopeT_
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
DDName is used to identify DDD entities uniquely.
std::vector< int > waferIndex_
static std::string & ns()
std::vector< double > thick_
std::vector< int > layers_
Log< level::Error, false > LogError
Compact representation of the geometrical detector hierarchy.
int32_t waferOrient(const int32_t property)
A DDSolid represents the shape of a part.
static std::string to_string(const XMLCh *ch)
std::vector< int > waferProperty_
Represents a uniquely identifyable rotation matrix.
static const std::string & rotName(const T &rot, const cms::DDParsingContext &context)
U second(std::pair< T, U > const &p)
HGCalGeomTools geomTools_
static constexpr int32_t WaferFull
std::vector< double > layerThick_
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< std::string > names_
Cos< T >::type cos(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 ...
void execute(DDCompactView &cpv) override
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
int32_t waferThick(const int32_t property)
std::vector< int > copyNumber_
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
static constexpr int32_t WaferCenterR
std::vector< int > layerOrient_
std::vector< int > waferLayerStart_
std::vector< double > zFrontB_
std::vector< std::string > waferPart_
std::vector< std::string > waferFull_
int32_t waferPartial(const int32_t property)
std::unordered_set< int > copies_
std::vector< double > rMinFront_
int32_t waferV(const int32_t index)
std::vector< int > layerType_
static int32_t packTypeUV(int type, int u, int v)
#define DEFINE_EDM_PLUGIN(factory, type, name)
Log< level::Warning, false > LogWarning
static int32_t layerType(int type)
static constexpr int32_t WaferCenterB
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)
std::vector< double > slopeB_