|
|
Go to the documentation of this file.
27 #include <unordered_set>
56 void positionSensitive(
62 static constexpr
double tol1_ = 0.01;
63 static constexpr
double tol2_ = 0.00001;
125 wafers_ = vsArgs[
"WaferNames"];
127 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << wafers_.size() <<
" wafers";
128 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
131 materials_ = vsArgs[
"MaterialNames"];
132 names_ = vsArgs[
"VolumeNames"];
133 thick_ = vArgs[
"Thickness"];
134 copyNumber_.resize(materials_.size(), 1);
136 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << materials_.size() <<
" types of volumes";
137 for (
unsigned int i = 0;
i < names_.size(); ++
i)
138 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
139 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
142 layerThick_ = vArgs[
"LayerThick"];
143 rMixLayer_ = vArgs[
"LayerRmix"];
145 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
146 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
147 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" Rmid " << rMixLayer_[
i]
148 <<
" with " << layers_[
i] <<
" layers";
151 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
152 firstLayer_ = (
int)(nArgs[
"FirstLayer"]);
153 absorbMode_ = (
int)(nArgs[
"AbsorberMode"]);
154 sensitiveMode_ = (
int)(nArgs[
"SensitiveMode"]);
157 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
159 layerCenter_ =
dbl_to_int(vArgs[
"LayerCenter"]);
161 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
164 if (firstLayer_ > 0) {
165 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
166 if (layerSense_[
i] > 0) {
167 int ii = layerType_[
i];
168 copyNumber_[
ii] = firstLayer_;
170 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with "
171 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
180 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
181 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
182 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
185 materialsTop_ = vsArgs[
"TopMaterialNames"];
186 namesTop_ = vsArgs[
"TopVolumeNames"];
187 layerThickTop_ = vArgs[
"TopLayerThickness"];
188 layerTypeTop_ =
dbl_to_int(vArgs[
"TopLayerType"]);
189 copyNumberTop_.resize(materialsTop_.size(), 1);
191 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << materialsTop_.size() <<
" types of volumes in the top part";
192 for (
unsigned int i = 0;
i < materialsTop_.size(); ++
i)
193 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesTop_[
i] <<
" of thickness " << layerThickTop_[
i]
194 <<
" filled with " << materialsTop_[
i] <<
" first copy number " << copyNumberTop_[
i];
195 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeTop_.size() <<
" layers in the top part";
196 for (
unsigned int i = 0;
i < layerTypeTop_.size(); ++
i)
197 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeTop_[
i];
199 materialsBot_ = vsArgs[
"BottomMaterialNames"];
200 namesBot_ = vsArgs[
"BottomVolumeNames"];
201 layerTypeBot_ =
dbl_to_int(vArgs[
"BottomLayerType"]);
202 layerSenseBot_ =
dbl_to_int(vArgs[
"BottomLayerSense"]);
203 layerThickBot_ = vArgs[
"BottomLayerThickness"];
204 copyNumberBot_.resize(materialsBot_.size(), 1);
206 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << materialsBot_.size()
207 <<
" types of volumes in the bottom part";
208 for (
unsigned int i = 0;
i < materialsBot_.size(); ++
i)
209 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesBot_[
i] <<
" of thickness " << layerThickBot_[
i]
210 <<
" filled with " << materialsBot_[
i] <<
" first copy number " << copyNumberBot_[
i];
211 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeBot_.size() <<
" layers in the bottom part";
212 for (
unsigned int i = 0;
i < layerTypeBot_.size(); ++
i)
213 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeBot_[
i]
214 <<
" sensitive class " << layerSenseBot_[
i];
216 zMinBlock_ = nArgs[
"zMinBlock"];
217 rad100to200_ = vArgs[
"rad100to200"];
218 rad200to300_ = vArgs[
"rad200to300"];
219 zMinRadPar_ = nArgs[
"zMinForRadPar"];
220 choiceType_ = (
int)(nArgs[
"choiceType"]);
221 nCutRadPar_ = (
int)(nArgs[
"nCornerCut"]);
222 fracAreaMin_ = nArgs[
"fracAreaMin"];
223 waferSize_ = nArgs[
"waferSize"];
224 waferSepar_ = nArgs[
"SensorSeparation"];
225 sectors_ = (
int)(nArgs[
"Sectors"]);
226 alpha_ = (1._pi) / sectors_;
227 cosAlpha_ =
cos(alpha_);
230 <<
" radius for wafer type separation uses " << rad100to200_.size()
231 <<
" parameters; zmin " << zMinRadPar_ <<
" cutoff " << choiceType_ <<
":"
232 << nCutRadPar_ <<
":" << fracAreaMin_ <<
" wafer width " << waferSize_
233 <<
" separations " << waferSepar_ <<
" sectors " << sectors_ <<
":"
235 for (
unsigned int k = 0;
k < rad100to200_.size(); ++
k)
236 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] 100-200 " << rad100to200_[
k] <<
" 200-300 " << rad200to300_[
k];
238 waferIndex_ =
dbl_to_int(vArgs[
"WaferIndex"]);
239 waferTypes_ =
dbl_to_int(vArgs[
"WaferTypes"]);
241 edm::LogVerbatim(
"HGCalGeom") <<
"waferTypes with " << waferTypes_.size() <<
" entries";
242 for (
unsigned int k = 0;
k < waferTypes_.size(); ++
k)
248 slopeB_ = vArgs[
"SlopeBottom"];
249 zFrontB_ = vArgs[
"ZFrontBottom"];
250 rMinFront_ = vArgs[
"RMinFront"];
251 slopeT_ = vArgs[
"SlopeTop"];
252 zFrontT_ = vArgs[
"ZFrontTop"];
253 rMaxFront_ = vArgs[
"RMaxFront"];
255 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
256 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
257 <<
" Slope " << slopeB_[
i];
258 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
259 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
260 <<
" Slope " << slopeT_[
i];
264 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: NameSpace " << nameSpace_;
279 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << copies_.size() <<
" different wafer copy numbers";
281 for (std::unordered_set<int>::const_iterator
itr = copies_.begin();
itr != copies_.end(); ++
itr, ++
k) {
285 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalHEFileAlgo construction...";
293 double zi(zMinBlock_);
295 for (
unsigned int i = 0;
i < layers_.size();
i++) {
296 double zo = zi + layerThick_[
i];
298 int laymax = laymin + layers_[
i];
301 for (
int ly = laymin; ly < laymax; ++ly) {
302 int ii = layerType_[ly];
303 int copy = copyNumber_[
ii];
304 double hthick = 0.5 * thick_[
ii];
307 thickTot += thick_[
ii];
311 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", "
312 << routF <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness "
318 if (layerSense_[ly] < 1) {
319 std::vector<double> pgonZ, pgonRin, pgonRout;
320 if (layerSense_[ly] == 0 || absorbMode_ == 0) {
323 pgonZ.emplace_back(-hthick);
324 pgonZ.emplace_back(hthick);
325 pgonRin.emplace_back(rinB);
326 pgonRin.emplace_back(rinB);
327 pgonRout.emplace_back(rmax);
328 pgonRout.emplace_back(rmax);
342 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
344 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
351 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << solid.
name() <<
" polyhedra of " << sectors_
353 <<
convertRadToDeg(-alpha_ + 2._pi) <<
" with " << pgonZ.size() <<
" sections";
354 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
355 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
364 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << solid.
name() <<
" Tubs made of " << matName
365 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
366 <<
", " << hthick <<
", 0.0, 360.0 and positioned in: " << glog.
name()
367 <<
" number " <<
copy;
369 positionMix(glog,
name,
copy, thick_[
ii], matter, rins, rMixLayer_[
i], routs,
zz, cpv);
377 << module.
name() <<
" at " <<
r1 <<
" with " <<
rot;
384 if (
std::abs(thickTot - layerThick_[
i]) >= tol2_) {
385 if (thickTot > layerThick_[
i]) {
386 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
387 <<
": thickness of all its components **** ERROR ****";
389 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with "
390 << thickTot <<
" of the components";
409 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
410 int ii = layerTypeTop_[ly];
411 copyNumberTop_[
ii] = copyM;
413 for (
unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
414 int ii = layerTypeBot_[ly];
415 copyNumberBot_[
ii] = copyM;
417 double hthick = 0.5 * thick;
424 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthick <<
", 0.0, 360.0";
429 <<
" at " << tran <<
" with " <<
rot;
431 double thickTot(0), zpos(-hthick);
432 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
433 int ii = layerTypeTop_[ly];
434 int copy = copyNumberTop_[
ii];
435 double hthickl = 0.5 * layerThickTop_[
ii];
436 thickTot += layerThickTop_[
ii];
439 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rmid <<
":" << rout
440 <<
" Thick " << layerThickTop_[
ii];
451 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << solid.
name() <<
" Tubs made of " << matName
452 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthickl <<
", 0.0, 360.0";
459 << glog1.
name() <<
" at " <<
r1 <<
" with " <<
rot;
461 ++copyNumberTop_[
ii];
464 if (
std::abs(thickTot - thick) >= tol2_) {
465 if (thickTot > thick) {
466 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
467 <<
": thickness of all its components in the top part **** ERROR ****";
469 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
470 <<
" of the components in top part";
475 name = nameM +
"Bottom";
480 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthick <<
", 0.0, 360.0";
485 <<
" at " << tran <<
" with " <<
rot;
489 for (
unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
490 int ii = layerTypeBot_[ly];
491 int copy = copyNumberBot_[
ii];
492 double hthickl = 0.5 * layerThickBot_[
ii];
493 thickTot += layerThickBot_[
ii];
496 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rin <<
":" << rmid
497 <<
" Thick " << layerThickBot_[
ii];
508 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << solid.
name() <<
" Tubs made of " << matName
509 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthickl <<
", 0.0, 360.0";
516 << glog1.
name() <<
" at " <<
r1 <<
" with " <<
rot;
518 if (layerSenseBot_[ly] != 0) {
521 << (
copy - firstLayer_) <<
":" << layerCenter_[
copy - firstLayer_];
523 positionSensitive(glog2, rin, rmid,
zz + zpos, layerSenseBot_[ly], (
copy - firstLayer_), cpv);
526 ++copyNumberBot_[
ii];
528 if (
std::abs(thickTot - thick) >= tol2_) {
529 if (thickTot > thick) {
530 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
531 <<
": thickness of all its components in the top part **** ERROR ****";
533 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
534 <<
" of the components in top part";
541 static const double sqrt3 =
std::sqrt(3.0);
542 int layercenter = layerCenter_[layer];
543 double r = 0.5 * (waferSize_ + waferSepar_);
544 double R = 2.0 *
r / sqrt3;
545 double dy = 0.75 *
R;
546 int N = (
int)(0.5 * rout /
r) + 2;
547 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
549 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0),
nin(0);
550 std::vector<int> ntype(6, 0);
551 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: " << glog.
ddname() <<
" rin:rout " << rin <<
":" << rout
552 <<
" zpos " << zpos <<
" N " <<
N <<
" for maximum u, v Offset; Shift " << xyoff.first
553 <<
":" << xyoff.second <<
" WaferSize " << (waferSize_ + waferSepar_);
555 for (
int u = -
N; u <=
N; ++u) {
556 for (
int v = -
N;
v <=
N; ++
v) {
563 double xpos = xyoff.first + nc *
r;
564 double ypos = xyoff.second +
nr *
dy;
575 <<
type <<
" layer:u:v:indx " << (layer + firstLayer_) <<
":" << u <<
":" <<
v
582 if (copies_.count(
copy) == 0)
583 copies_.insert(
copy);
602 <<
":" <<
type <<
" positioned in " << glog.
ddname() <<
" at " << tran
610 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEFileAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
611 <<
":" << ivmAll <<
" and " <<
nin <<
":" << kount <<
":" << ntot <<
" wafers ("
612 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":" << ntype[4]
613 <<
":" << ntype[5] <<
") for " << glog.
ddname() <<
" R " << rin <<
":" << rout;
static int32_t waferV(const int32_t index)
void positionMix(const DDLogicalPart &glog, const std::string &name, int copy, double thick, const DDMaterial &matter, double rin, double rmid, double routF, double zz, DDCompactView &cpv)
std::vector< std::string > namesBot_
std::vector< int > layerTypeTop_
std::vector< int > copyNumber_
std::vector< int > waferTypes_
std::vector< double > rMaxFront_
DDName is used to identify DDD entities uniquely.
constexpr NumType convertRadToDeg(NumType radians)
std::vector< int > layers_
static constexpr uint32_t k_CornerSize
U second(std::pair< T, U > const &p)
HGCalGeomTools geomTools_
std::vector< double > slopeT_
std::vector< double > rad100to200_
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
std::vector< double > zFrontB_
std::vector< std::string > wafers_
Log< level::Warning, false > LogWarning
std::vector< double > rad200to300_
DDMaterial is used to define and access material information.
Cos< T >::type cos(const T &t)
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< std::string > materialsTop_
Compact representation of the geometrical detector hierarchy.
std::vector< int > layerType_
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
int getType(double xpos, double ypos, double zpos)
#define DEFINE_EDM_PLUGIN(factory, type, name)
static int32_t waferU(const int32_t index)
std::vector< double > rMinFront_
static int32_t packTypeUV(int type, int u, int v)
std::vector< int > copyNumberTop_
std::vector< std::string > namesTop_
std::vector< double > thick_
std::vector< int > layerTypeBot_
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Tan< T >::type tan(const T &t)
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
std::vector< double > layerThickTop_
Log< level::Error, false > LogError
std::unordered_set< int > copies_
std::vector< std::pair< float, float > >::iterator itr
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< int > waferIndex_
std::vector< std::string > names_
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)
Log< level::Info, true > LogVerbatim
std::vector< double > layerThickBot_
std::vector< double > zFrontT_
std::vector< std::string > materialsBot_
static std::string & ns()
std::vector< std::string > materials_
static int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
A DDSolid represents the shape of a part.
std::vector< int > layerSenseBot_
Represents a uniquely identifyable rotation matrix.
std::vector< double > rMixLayer_
std::vector< double > layerThick_
void positionSensitive(const DDLogicalPart &glog, double rin, double rout, double zpos, int layertype, int layer, DDCompactView &cpv)
static AlgebraicMatrix initialize()
std::vector< int > layerSense_
Abs< T >::type abs(const T &t)
std::vector< int > copyNumberBot_
std::vector< int > layerCenter_
std::vector< double > slopeB_
void execute(DDCompactView &cpv) override
static int32_t waferLayer(const int32_t index)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string ©no, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)