32 #include <unordered_set> 57 static constexpr
double tol1_ = 0.01;
58 static constexpr
double tol2_ = 0.00001;
101 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: Creating an instance";
110 waferTypes_ =
static_cast<int>(nArgs[
"WaferTypes"]);
111 facingTypes_ =
static_cast<int>(nArgs[
"FacingTypes"]);
112 orientationTypes_ =
static_cast<int>(nArgs[
"OrientationTypes"]);
113 placeOffset_ =
static_cast<int>(nArgs[
"PlaceOffset"]);
115 edm::LogVerbatim(
"HGCalGeom") <<
"Number of types of wafers: " << waferTypes_ <<
" facings: " << facingTypes_
116 <<
" Orientations: " << orientationTypes_ <<
" PlaceOffset: " << placeOffset_;
118 firstLayer_ =
static_cast<int>(nArgs[
"FirstLayer"]);
119 absorbMode_ =
static_cast<int>(nArgs[
"AbsorberMode"]);
120 sensitiveMode_ =
static_cast<int>(nArgs[
"SensitiveMode"]);
123 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
125 zMinBlock_ = nArgs[
"zMinBlock"];
126 waferSize_ = nArgs[
"waferSize"];
127 waferSepar_ = nArgs[
"SensorSeparation"];
128 sectors_ =
static_cast<int>(nArgs[
"Sectors"]);
129 cassettes_ =
static_cast<int>(nArgs[
"Cassettes"]);
130 alpha_ = (1._pi) / sectors_;
131 cosAlpha_ =
cos(alpha_);
132 rotstr_ = sArgs[
"LayerRotation"];
134 edm::LogVerbatim(
"HGCalGeom") <<
"zStart " << zMinBlock_ <<
" wafer width " << waferSize_ <<
" separations " 135 << waferSepar_ <<
" sectors " << sectors_ <<
":" <<
convertRadToDeg(alpha_) <<
":" 136 << cosAlpha_ <<
" rotation matrix " << rotstr_ <<
" with " << cassettes_
139 waferFull_ = vsArgs[
"WaferNamesFull"];
140 waferPart_ = vsArgs[
"WaferNamesPartial"];
142 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: " << waferFull_.size() <<
" full and " 143 << waferPart_.size() <<
" partial modules\nDDHGCalSiliconRotatedModule:Full Modules:";
144 unsigned int i1max =
static_cast<unsigned int>(waferFull_.size());
145 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
146 std::ostringstream st1;
148 for (
unsigned int i =
i1;
i <
i2; ++
i)
149 st1 <<
" [" <<
i <<
"] " << waferFull_[
i];
152 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: Partial Modules:";
153 i1max =
static_cast<unsigned int>(waferPart_.size());
154 for (
unsigned int i1 = 0;
i1 < i1max;
i1 += 2) {
155 std::ostringstream st1;
157 for (
unsigned int i =
i1;
i <
i2; ++
i)
158 st1 <<
" [" <<
i <<
"] " << waferPart_[
i];
162 materials_ = vsArgs[
"MaterialNames"];
163 names_ = vsArgs[
"VolumeNames"];
164 thick_ = vArgs[
"Thickness"];
165 copyNumber_.resize(materials_.size(), 1);
167 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: " << materials_.size() <<
" types of volumes";
168 for (
unsigned int i = 0;
i < names_.size(); ++
i)
169 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
170 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
173 layerThick_ = vArgs[
"LayerThick"];
175 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
176 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
177 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" with " << layers_[
i]
181 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
182 layerOrient_ =
dbl_to_int(vArgs[
"LayerTypes"]);
183 for (
unsigned int k = 0;
k < layerOrient_.size(); ++
k)
186 for (
unsigned int i = 0;
i < layerOrient_.size(); ++
i)
189 if (firstLayer_ > 0) {
190 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
191 if (layerSense_[
i] > 0) {
192 int ii = layerType_[
i];
193 copyNumber_[
ii] = (layerSense_[
i] == 1) ? firstLayer_ : (firstLayer_ + 1);
195 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with " 196 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
204 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
205 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
206 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class " 209 slopeB_ = vArgs[
"SlopeBottom"];
210 zFrontB_ = vArgs[
"ZFrontBottom"];
211 rMinFront_ = vArgs[
"RMinFront"];
212 slopeT_ = vArgs[
"SlopeTop"];
213 zFrontT_ = vArgs[
"ZFrontTop"];
214 rMaxFront_ = vArgs[
"RMaxFront"];
216 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
217 edm::LogVerbatim(
"HGCalGeom") <<
"Bottom Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
218 <<
" Slope " << slopeB_[
i];
219 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
220 edm::LogVerbatim(
"HGCalGeom") <<
"Top Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
221 <<
" Slope " << slopeT_[
i];
223 waferIndex_ =
dbl_to_int(vArgs[
"WaferIndex"]);
224 waferProperty_ =
dbl_to_int(vArgs[
"WaferProperties"]);
225 waferLayerStart_ =
dbl_to_int(vArgs[
"WaferLayerStart"]);
226 cassetteShift_ = vArgs[
"CassetteShift"];
228 edm::LogVerbatim(
"HGCalGeom") <<
"waferProperties with " << waferIndex_.size() <<
" entries in " 229 << waferLayerStart_.size() <<
" layers";
230 for (
unsigned int k = 0;
k < waferLayerStart_.size(); ++
k)
232 for (
unsigned int k = 0;
k < waferIndex_.size(); ++
k)
240 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: " << cassetteShift_.size()
241 <<
" elements for cassette shifts";
242 unsigned int j1max = cassetteShift_.size();
243 for (
unsigned int j1 = 0; j1 < j1max; j1 += 6) {
244 std::ostringstream st1;
245 unsigned int j2 =
std::min((j1 + 6), j1max);
246 for (
unsigned int j = j1;
j < j2; ++
j)
247 st1 <<
" [" <<
j <<
"] " << std::setw(9) << cassetteShift_[
j];
253 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: NameSpace " << nameSpace_ <<
":";
255 cassette_.setParameter(cassettes_, cassetteShift_);
264 edm::LogVerbatim(
"HGCalGeom") <<
"==>> Constructing DDHGCalSiliconRotatedModule...";
269 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: " << copies_.size() <<
" different wafer copy numbers";
271 for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++
k) {
275 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalSiliconRotatedModule construction...";
280 double zi(zMinBlock_);
282 for (
unsigned int i = 0;
i < layers_.size();
i++) {
283 double zo = zi + layerThick_[
i];
285 int laymax = laymin + layers_[
i];
288 for (
int ly = laymin; ly < laymax; ++ly) {
289 int ii = layerType_[ly];
290 int copy = copyNumber_[
ii];
291 double hthick = 0.5 * thick_[
ii];
294 thickTot += thick_[
ii];
298 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: Layer " << ly <<
":" <<
ii <<
" Front " << zi
299 <<
", " << routF <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " 305 if (layerSense_[ly] < 1) {
306 std::vector<double> pgonZ, pgonRin, pgonRout;
307 double rmax = routF * cosAlpha_ - tol1_;
320 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
322 if (layerSense_[ly] == 0 || absorbMode_ == 0)
323 pgonRout[isec] = rmax;
325 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
331 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: " << solid.
name() <<
" polyhedra of " << sectors_
334 <<
" sections and filled with " << matName;
335 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
336 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
346 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: " << solid.
name() <<
" Tubs made of " << matName
347 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
348 <<
", " << hthick <<
", 0.0, 360.0 and position " << glog.
name() <<
" number " 349 <<
copy <<
":" << layerOrient_[
copy - firstLayer_];
351 positionSensitive(glog, (
copy - firstLayer_), cpv);
365 int inc = ((layerSense_[ly] > 0) && (facingTypes_ > 1)) ? 2 : 1;
366 copyNumber_[
ii] =
copy + inc;
369 <<
" positioned in " <<
module.name() <<
" at " << r1 <<
" with " <<
rotName 377 if (
std::abs(thickTot - layerThick_[
i]) >= tol2_) {
378 if (thickTot > layerThick_[
i]) {
379 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
380 <<
": thickness of all its components **** ERROR ****";
382 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with " 383 << thickTot <<
" of the components";
391 static const double sqrt3 =
std::sqrt(3.0);
392 int layercenter = layerOrient_[layer];
394 int firstWafer = waferLayerStart_[layer];
395 int lastWafer = ((layer + 1 <
static_cast<int>(waferLayerStart_.size())) ? waferLayerStart_[layer + 1]
396 :
static_cast<int>(waferIndex_.size()));
397 double delx = 0.5 * (waferSize_ + waferSepar_);
398 double dely = 2.0 * delx / sqrt3;
399 double dy = 0.75 * dely;
400 const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
402 int ium(0), ivm(0), kount(0);
403 std::vector<int> ntype(3, 0);
404 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: " << glog.
ddname() <<
" r " << delx <<
" R " << dely
405 <<
" dy " <<
dy <<
" Shift " << xyoff.first <<
":" << xyoff.second <<
" WaferSize " 406 << (waferSize_ + waferSepar_) <<
" index " << firstWafer <<
":" << (lastWafer - 1)
407 <<
" Layer Center " << layercenter <<
":" << layertype;
409 for (
int k = firstWafer;
k < lastWafer; ++
k) {
423 auto cshift = cassette_.getShift(layer + 1, -1, cassette);
424 double xpos = xyoff.first - cshift.first + nc * delx;
425 double ypos = xyoff.second + cshift.second +
nr *
dy;
427 double xorig = xyoff.first + nc * delx;
428 double yorig = xyoff.second +
nr *
dy;
429 double angle = std::atan2(yorig, xorig);
430 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule::Wafer: layer " << layer + 1 <<
" cassette " 431 << cassette <<
" Shift " << cshift.first <<
":" << cshift.second <<
" Original " 433 << ypos <<
" u|v " << u <<
":" <<
v <<
" type|part|orient|place " <<
type <<
":" 434 <<
part <<
":" << orien <<
":" << place;
439 i =
type * facingTypes_ * orientationTypes_ + place - placeOffset_;
440 wafer = waferFull_[
i];
442 edm::LogVerbatim(
"HGCalGeom") <<
" layertype:type:part:orien:cassette:place:offsets:ind " << layertype <<
":" 443 <<
type <<
":" <<
part <<
":" << orien <<
":" << cassette <<
":" << place <<
":" 444 << placeOffset_ <<
":" << facingTypes_ <<
":" << orientationTypes_ <<
" wafer " <<
i 449 i = (
part - partoffset) * facingTypes_ * orientationTypes_ +
452 edm::LogVerbatim(
"HGCalGeom") <<
" layertype:type:part:orien:cassette:place:offsets:ind " << layertype <<
":" 453 <<
type <<
":" <<
part <<
":" << orien <<
":" << cassette <<
":" << place <<
":" 455 << waferPart_.size();
457 wafer = waferPart_[
i];
463 <<
copy <<
" type:part:orien:ind " <<
type <<
":" <<
part <<
":" << orien <<
":" <<
i 464 <<
" layer:u:v:indx " << (layer + firstLayer_) <<
":" << u <<
":" <<
v;
470 if (copies_.count(
copy) == 0)
471 copies_.insert(
copy);
480 << layertype <<
":" <<
type <<
" positioned in " << glog.
ddname() <<
" at " << tran
481 <<
" with no rotation";
485 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalSiliconRotatedModule: Maximum # of u " << ium <<
" # of v " << ivm <<
" and " 486 << kount <<
" wafers (" << ntype[0] <<
":" << ntype[1] <<
":" << ntype[2] <<
") for "
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
static int32_t cellPlacementIndex(int32_t iz, int32_t frontBack, int32_t orient)
static constexpr int32_t WaferPartLDOffset
std::vector< int > copyNumber_
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string ©no, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
static constexpr int32_t WaferTypeOffset[3]
std::vector< double > rMinFront_
std::vector< double > thick_
DDMaterial is used to define and access material information.
std::vector< double > rMaxFront_
int32_t waferU(const int32_t index)
int32_t waferLayer(const int32_t index)
constexpr NumType convertRadToDeg(NumType radians)
std::vector< int > waferIndex_
DDName is used to identify DDD entities uniquely.
void positionSensitive(const DDLogicalPart &glog, int layer, DDCompactView &cpv)
static std::string & ns()
std::vector< std::string > waferFull_
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)
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)
int32_t waferCassette(const int32_t property)
static constexpr int32_t WaferFull
std::vector< int > layerOrient_
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 ...
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< double > slopeT_
std::vector< double > cassetteShift_
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 WaferPartHDOffset
static constexpr int32_t WaferCenterR
std::vector< double > slopeB_
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
std::vector< int > waferLayerStart_
DDHGCalSiliconRotatedModule()
HGCalGeomTools geomTools_
std::unordered_set< int > copies_
std::vector< std::string > materials_
std::vector< int > layers_
std::vector< std::string > names_
int32_t waferPartial(const int32_t property)
std::vector< double > zFrontB_
std::vector< double > zFrontT_
int32_t waferV(const int32_t index)
std::vector< int > layerSense_
std::vector< double > layerThick_
static int32_t packTypeUV(int type, int u, int v)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< int > layerType_
static constexpr int32_t WaferHDTop
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< int > waferProperty_
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< std::string > waferPart_
void execute(DDCompactView &cpv) override
T angle(T x1, T y1, T z1, T x2, T y2, T z2)