29 #include <unordered_set> 48 void positionSensitive(
98 wafers_ = vsArgs[
"WaferNames"];
100 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << wafers_.size() <<
" wafers";
101 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
104 materials_ = vsArgs[
"MaterialNames"];
105 names_ = vsArgs[
"VolumeNames"];
106 thick_ = vArgs[
"Thickness"];
107 copyNumber_.resize(materials_.size(), 1);
109 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << materials_.size() <<
" types of volumes";
110 for (
unsigned int i = 0;
i < names_.size(); ++
i)
111 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
112 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
115 layerThick_ = vArgs[
"LayerThick"];
117 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
118 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
119 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" with " << layers_[
i]
123 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
124 firstLayer_ = (
int)(nArgs[
"FirstLayer"]);
125 absorbMode_ = (
int)(nArgs[
"AbsorberMode"]);
126 sensitiveMode_ = (
int)(nArgs[
"SensitiveMode"]);
129 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
131 layerCenter_ =
dbl_to_int(vArgs[
"LayerCenter"]);
133 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
136 if (firstLayer_ > 0) {
137 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
138 if (layerSense_[
i] > 0) {
139 int ii = layerType_[
i];
140 copyNumber_[
ii] = firstLayer_;
142 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with " 143 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
152 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
153 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
154 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class " 157 zMinBlock_ = nArgs[
"zMinBlock"];
158 waferSize_ = nArgs[
"waferSize"];
159 waferSepar_ = nArgs[
"SensorSeparation"];
160 sectors_ = (
int)(nArgs[
"Sectors"]);
161 alpha_ = (1._pi) / sectors_;
162 cosAlpha_ =
cos(alpha_);
164 edm::LogVerbatim(
"HGCalGeom") <<
"zStart " << zMinBlock_ <<
" wafer width " << waferSize_ <<
" separations " 165 << waferSepar_ <<
" sectors " << sectors_ <<
":" <<
convertRadToDeg(alpha_) <<
":" 168 waferIndex_ =
dbl_to_int(vArgs[
"WaferIndex"]);
169 waferProperty_ =
dbl_to_int(vArgs[
"WaferProperties"]);
171 edm::LogVerbatim(
"HGCalGeom") <<
"waferProperties with " << waferIndex_.size() <<
" entries";
172 for (
unsigned int k = 0;
k < waferIndex_.size(); ++
k)
181 slopeB_ = vArgs[
"SlopeBottom"];
182 zFrontB_ = vArgs[
"ZFrontBottom"];
183 rMinFront_ = vArgs[
"RMinFront"];
184 slopeT_ = vArgs[
"SlopeTop"];
185 zFrontT_ = vArgs[
"ZFrontTop"];
186 rMaxFront_ = vArgs[
"RMaxFront"];
188 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
189 edm::LogVerbatim(
"HGCalGeom") <<
"Bottom Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
190 <<
" Slope " << slopeB_[
i];
191 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
192 edm::LogVerbatim(
"HGCalGeom") <<
"Top Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
193 <<
" Slope " << slopeT_[
i];
197 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: NameSpace " << nameSpace_ <<
":";
212 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << copies_.size() <<
" different wafer copy numbers";
214 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
218 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalEEFileAlgo construction...";
223 double zi(zMinBlock_);
225 for (
unsigned int i = 0;
i < layers_.size();
i++) {
226 double zo = zi + layerThick_[
i];
228 int laymax = laymin + layers_[
i];
231 for (
int ly = laymin; ly < laymax; ++ly) {
232 int ii = layerType_[ly];
233 int copy = copyNumber_[
ii];
234 double hthick = 0.5 * thick_[
ii];
237 thickTot += thick_[
ii];
241 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " 242 << routF <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " 248 if (layerSense_[ly] < 1) {
249 std::vector<double> pgonZ, pgonRin, pgonRout;
250 double rmax = routF * cosAlpha_ - tol1_;
263 for (
unsigned int isec = 0;
isec < pgonZ.size(); ++
isec) {
265 if (layerSense_[ly] == 0 || absorbMode_ == 0)
266 pgonRout[
isec] = rmax;
268 pgonRout[
isec] = pgonRout[
isec] * cosAlpha_ - tol1_;
274 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << solid.
name() <<
" polyhedra of " << sectors_
277 <<
" sections and filled with " << matName;
278 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
279 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
289 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << solid.
name() <<
" Tubs made of " << matName
290 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
291 <<
", " << hthick <<
", 0.0, 360.0 and position " << glog.
name() <<
" number " 292 <<
copy <<
":" << layerCenter_[
copy - firstLayer_];
294 positionSensitive(glog, rins, routs,
zz, layerSense_[ly], (
copy - firstLayer_), cpv);
302 <<
module.name() <<
" at " << r1 <<
" with no rotation";
309 if (
std::abs(thickTot - layerThick_[
i]) >= tol2_) {
310 if (thickTot > layerThick_[
i]) {
311 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
312 <<
": thickness of all its components **** ERROR ****";
314 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with " 315 << thickTot <<
" of the components";
323 static const double sqrt3 =
std::sqrt(3.0);
324 int layercenter = layerCenter_[layer];
325 double r = 0.5 * (waferSize_ + waferSepar_);
326 double R = 2.0 * r / sqrt3;
327 double dy = 0.75 *
R;
328 int N = (
int)(0.5 * rout / r) + 2;
329 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
331 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0),
ntot(0), nin(0);
332 std::vector<int> ntype(6, 0);
333 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: " << glog.
ddname() <<
" rin:rout " << rin <<
":" << rout
334 <<
" zpos " << zpos <<
" N " <<
N <<
" for maximum u, v; r " << r <<
" R " <<
R 335 <<
" dy " <<
dy <<
" Shift " << xyoff.first <<
":" << xyoff.second <<
" WaferSize " 336 << (waferSize_ + waferSepar_);
338 for (
int u = -
N; u <=
N; ++u) {
339 for (
int v = -
N;
v <=
N; ++
v) {
346 double xpos = xyoff.first + nc * r;
347 double ypos = xyoff.second +
nr *
dy;
353 <<
"\n Z " << zpos <<
" LayerType " << layertype <<
" u " << u <<
" v " <<
v 354 <<
" with " <<
corner.first <<
" corners";
365 <<
type <<
" layer:u:v:indx " << (layer + firstLayer_) <<
":" << u <<
":" <<
v 372 if (copies_.count(
copy) == 0)
373 copies_.insert(
copy);
390 <<
":" <<
type <<
" positioned in " << glog.
ddname() <<
" at " << tran
391 <<
" with no rotation";
398 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalEEFileAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm
399 <<
":" << ivmAll <<
" and " << nin <<
":" << kount <<
":" <<
ntot <<
" wafers (" 400 << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":" << ntype[4]
401 <<
":" << ntype[5] <<
") for " << glog.
ddname() <<
" R " << rin <<
":" << rout;
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
static int getType(int index, const HGCalParameters::waferInfo_map &wafers)
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)
DDMaterial is used to define and access material information.
int32_t waferU(const int32_t index)
int32_t waferLayer(const int32_t index)
std::vector< std::string > wafers_
constexpr NumType convertRadToDeg(NumType radians)
std::vector< double > zFrontT_
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.
static std::string & ns()
void execute(DDCompactView &cpv) override
Log< level::Error, false > LogError
Compact representation of the geometrical detector hierarchy.
std::vector< std::string > materials_
std::vector< int > copyNumber_
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< double > zFrontB_
static constexpr uint32_t k_CornerSize
Represents a uniquely identifyable rotation matrix.
std::vector< int > waferIndex_
U second(std::pair< T, U > const &p)
HGCalGeomTools geomTools_
std::unordered_set< int > copies_
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 ...
std::vector< double > slopeT_
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< std::string > names_
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
std::vector< int > layerCenter_
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 > thick_
std::vector< double > slopeB_
std::vector< double > rMaxFront_
std::vector< double > rMinFront_
void positionSensitive(const DDLogicalPart &glog, double rin, double rout, double zpos, int layertype, int layer, DDCompactView &cpv)
int32_t waferPartial(const int32_t property)
int32_t waferV(const int32_t index)
static int32_t packTypeUV(int type, int u, int v)
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< int > layerType_
Log< level::Warning, false > LogWarning
std::vector< double > layerThick_
std::vector< int > waferProperty_
std::vector< int > layers_
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)