Skip to content

Commit 462b788

Browse files
authored
Merge pull request #47775 from bsunanda/Phase2-hgx363A
Phase2-hgx363A Update the dd4hep versions of V19 algorithms of HGCal geometry
2 parents aca8d21 + 49e6c85 commit 462b788

File tree

2 files changed

+107
-77
lines changed

2 files changed

+107
-77
lines changed

Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedFineCassette.cc

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ struct HGCalMixRotatedFineCassette {
121121
#endif
122122
passiveFull_ = args.value<std::vector<std::string>>("PassiveNamesFull");
123123
passivePart_ = args.value<std::vector<std::string>>("PassiveNamesPartial");
124+
if (passiveFull_.size() <= 1)
125+
passiveFull_.clear();
126+
if (passivePart_.size() <= 1)
127+
passivePart_.clear();
124128
#ifdef EDM_ML_DEBUG
125129
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << passiveFull_.size() << " full and "
126130
<< passivePart_.size() << " partial passive modules";
@@ -334,7 +338,7 @@ struct HGCalMixRotatedFineCassette {
334338
#endif
335339
dd4hep::Material matter = ns.material(materials_[ii]);
336340
dd4hep::Volume glog;
337-
if (layerSense_[ly] == 0) {
341+
if (layerSense_[ly] <= 0) {
338342
std::vector<double> pgonZ, pgonRin, pgonRout;
339343
double rmax =
340344
(std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, rMaxFront_, slopeT_)) * cosAlpha_) - tol1;
@@ -369,10 +373,20 @@ struct HGCalMixRotatedFineCassette {
369373
edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << cms::convert2mm(pgonZ[k]) << " R "
370374
<< cms::convert2mm(pgonRin[k]) << ":" << cms::convert2mm(pgonRout[k]);
371375
#endif
376+
if (layerSense_[ly] < 0) {
377+
int absType = -layerSense_[ly];
378+
unsigned int num = (absType <= waferTypes_) ? passiveFull_.size() : passivePart_.size();
379+
#ifdef EDM_ML_DEBUG
380+
edm::LogVerbatim("HGCalGeom") << "Abstype " << absType << " num " << num;
381+
#endif
382+
if (num > 1)
383+
positionMix(ctxt, e, glog, name, copy, thick_[ii], matter, absType, fine);
384+
}
372385
} else {
373-
int mode = (layerSense_[ly] > 0) ? sensitiveMode_ : absorbMode_;
374-
double rins = (mode < 1) ? rinB : HGCalGeomTools::radius(zz + hthick, zFrontB_, rMinFront_, slopeB_);
375-
double routs = (mode < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_);
386+
double rins =
387+
(sensitiveMode_ < 1) ? rinB : HGCalGeomTools::radius(zz + hthick, zFrontB_, rMinFront_, slopeB_);
388+
double routs =
389+
(sensitiveMode_ < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_);
376390
dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi);
377391
ns.addSolidNS(ns.prepend(name), solid);
378392
glog = dd4hep::Volume(solid.name(), solid, matter);

Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalSiliconRotatedCassette.cc

Lines changed: 89 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,30 @@ struct HGCalSiliconRotatedCassette {
9898
edm::LogVerbatim("HGCalGeom") << st1.str();
9999
}
100100
#endif
101-
passiveFull_ = args.value<std::vector<std::string>>("PassiveNamesFull");
102-
passivePart_ = args.value<std::vector<std::string>>("PassiveNamesPartial");
103-
#ifdef EDM_ML_DEBUG
104-
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << passiveFull_.size() << " full and "
105-
<< passivePart_.size() << " partial passive modules";
106-
i1max = static_cast<unsigned int>(passiveFull_.size());
101+
passiveAbsorb_ = args.value<std::vector<std::string>>("PassiveNamesFull");
102+
passiveCool_ = args.value<std::vector<std::string>>("PassiveNamesPartial");
103+
if ((passiveAbsorb_.size() == 1) && (passiveAbsorb_[0] == "NULL"))
104+
passiveAbsorb_.clear();
105+
if ((passiveCool_.size() == 1) && (passiveCool_[0] == "NULL"))
106+
passiveCool_.clear();
107+
#ifdef EDM_ML_DEBUG
108+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << passiveAbsorb_.size() << " full and "
109+
<< passiveCool_.size() << " partial passive modules";
110+
i1max = static_cast<unsigned int>(passiveAbsorb_.size());
107111
for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
108112
std::ostringstream st1;
109113
unsigned int i2 = std::min((i1 + 2), i1max);
110114
for (unsigned int i = i1; i < i2; ++i)
111-
st1 << " [" << i << "] " << passiveFull_[i];
115+
st1 << " [" << i << "] " << passiveAbsorb_[i];
112116
edm::LogVerbatim("HGCalGeom") << st1.str();
113117
}
114118
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Partial Modules:";
115-
i1max = static_cast<unsigned int>(passivePart_.size());
119+
i1max = static_cast<unsigned int>(passiveCool_.size());
116120
for (unsigned int i1 = 0; i1 < i1max; i1 += 2) {
117121
std::ostringstream st1;
118122
unsigned int i2 = std::min((i1 + 2), i1max);
119123
for (unsigned int i = i1; i < i2; ++i)
120-
st1 << " [" << i << "] " << passivePart_[i];
124+
st1 << " [" << i << "] " << passiveCool_[i];
121125
edm::LogVerbatim("HGCalGeom") << st1.str();
122126
}
123127
#endif
@@ -226,6 +230,10 @@ struct HGCalSiliconRotatedCassette {
226230
int laymax = laymin + layers_[i];
227231
double zz = zi;
228232
double thickTot(0);
233+
#ifdef EDM_ML_DEBUG
234+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Section " << i << " Layers " << laymin << ":"
235+
<< laymax << " zi " << cms::convert2mm(zi);
236+
#endif
229237
for (int ly = laymin; ly < laymax; ++ly) {
230238
int ii = layerType_[ly];
231239
int copy = copyNumber_[ii];
@@ -297,7 +305,10 @@ struct HGCalSiliconRotatedCassette {
297305
if (layerSense_[ly] > 0) {
298306
positionSensitive(ctxt, e, glog, (copy - firstLayer_));
299307
} else if (passiveMode_ > 0) {
300-
positionPassive2(ctxt, e, glog, (copy - firstLayer_), -layerSense_[ly]);
308+
unsigned int num = (-layerSense_[ly] <= waferTypes_) ? passiveAbsorb_.size() : passiveCool_.size();
309+
if (num > 0)
310+
positionPassiveNew(ctxt, e, glog, i, -layerSense_[ly]);
311+
// positionPassiveNew(ctxt, e, glog, (copy - firstLayer_), -layerSense_[ly]);
301312
} else {
302313
positionPassive(ctxt, e, glog, (copy - firstLayer_), -layerSense_[ly]);
303314
}
@@ -510,7 +521,7 @@ struct HGCalSiliconRotatedCassette {
510521
int i(999);
511522
if (part == HGCalTypes::WaferFull) {
512523
i = absType - 1;
513-
passive = passiveFull_[i];
524+
passive = passiveAbsorb_[i];
514525
#ifdef EDM_ML_DEBUG
515526
edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:offsets:ind " << layertype << ":"
516527
<< absType << ":" << part << ":" << orien << ":" << cassette << ":"
@@ -527,9 +538,9 @@ struct HGCalSiliconRotatedCassette {
527538
edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:3Types:offset:ind " << layertype << ":"
528539
<< absType << ":" << part << ":" << orien << ":" << cassette << ":"
529540
<< partialTypes_ << ":" << facingTypes_ << ":" << orientationTypes_ << ":"
530-
<< partoffset << ":" << i << ":" << passivePart_.size();
541+
<< partoffset << ":" << i << ":" << passiveCool_.size();
531542
#endif
532-
passive = passivePart_[i];
543+
passive = passiveCool_[i];
533544
}
534545
int copy = HGCalTypes::packTypeUV(absType, u, v);
535546
#ifdef EDM_ML_DEBUG
@@ -560,37 +571,42 @@ struct HGCalSiliconRotatedCassette {
560571
}
561572

562573
// Position the passive modules (mode > 0)
563-
void positionPassive2(cms::DDParsingContext& ctxt, xml_h e, const dd4hep::Volume& glog, int layer, int absType) {
574+
void positionPassiveNew(cms::DDParsingContext& ctxt, xml_h e, const dd4hep::Volume& glog, int layer, int absType) {
564575
cms::DDNamespace ns(ctxt, e, true);
565576
#ifdef EDM_ML_DEBUG
566-
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: positionPassive2 is called";
577+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: positionPassiveNew is called";
567578
int kount(0);
579+
#endif
580+
bool type = (absType <= waferTypes_);
581+
int num = type ? (passiveAbsorb_.size() / (cassettes_ * layers_.size()))
582+
: (passiveCool_.size() / (cassettes_ * layers_.size()));
583+
#ifdef EDM_ML_DEBUG
584+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Type " << type << " number per cassette " << num;
568585
#endif
569586
for (int k = 0; k < cassettes_; ++k) {
570-
int cassette = k + 1;
571-
auto cshift = cassette_.getShift(layer + 1, -1, cassette);
572-
double xpos = -cshift.first;
573-
double ypos = cshift.second;
574-
int i = layer * cassettes_ + k;
587+
double xpos(0), ypos(0);
588+
for (int n = 0; n < num; ++n) {
589+
int i1 = num * k + n;
590+
int i2 = num * layer * cassettes_ + i1;
575591
#ifdef EDM_ML_DEBUG
576-
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive2: layer " << layer + 1 << " cassette "
577-
<< cassette << " Shift " << cms::convert2mm(cshift.first) << ":"
578-
<< cms::convert2mm(cshift.second) << " PassiveIndex " << i << ":"
579-
<< passiveFull_.size() << ":" << passivePart_.size();
592+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive2: layer " << layer + 1 << " cassette "
593+
<< " PassiveIndex " << i1 << ":" << i2 << ":" << passiveAbsorb_.size() << ":"
594+
<< passiveCool_.size();
580595
#endif
581-
std::string passive = (absType <= waferTypes_) ? passiveFull_[i] : passivePart_[i];
596+
std::string passive = (type) ? passiveAbsorb_[i2] : passiveCool_[i2];
582597
#ifdef EDM_ML_DEBUG
583-
edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: Passive2 " << passive << " number " << cassette
584-
<< " pos " << cms::convert2mm(xpos) << ":" << cms::convert2mm(ypos);
585-
kount++;
598+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive2 " << passive << " number " << i2
599+
<< " pos " << cms::convert2mm(xpos) << ":" << cms::convert2mm(ypos) << ":0";
600+
kount++;
586601
#endif
587-
dd4hep::Position tran(xpos, ypos, 0.0);
588-
glog.placeVolume(ns.volume(passive), cassette, tran);
602+
dd4hep::Position tran(xpos, ypos, 0.0);
603+
glog.placeVolume(ns.volume(passive), i2, tran);
589604
#ifdef EDM_ML_DEBUG
590-
edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: " << passive << " number " << cassette
591-
<< " positioned in " << glog.name() << " at (" << cms::convert2mm(xpos) << ","
592-
<< cms::convert2mm(ypos) << ",0) with no rotation";
605+
edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: " << passive << " number " << i2
606+
<< " positioned in " << glog.name() << " at (" << cms::convert2mm(xpos) << ","
607+
<< cms::convert2mm(ypos) << ",0) with no rotation";
593608
#endif
609+
}
594610
}
595611
#ifdef EDM_ML_DEBUG
596612
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << kount << " passives of type " << absType
@@ -602,46 +618,46 @@ struct HGCalSiliconRotatedCassette {
602618
HGCalGeomTools geomTools_;
603619
HGCalCassette cassette_;
604620

605-
int waferTypes_; // Number of wafer types
606-
int passiveTypes_; // Number of passive types
607-
int facingTypes_; // Types of facings of modules toward IP
608-
int orientationTypes_; // Number of wafer orienations
609-
int partialTypes_; // Number of partial types
610-
int placeOffset_; // Offset for placement
611-
int firstLayer_; // Copy # of the first sensitive layer
612-
int absorbMode_; // Absorber mode
613-
int sensitiveMode_; // Sensitive mode
614-
int passiveMode_; // Mode for passive volumes
615-
double zMinBlock_; // Starting z-value of the block
616-
double waferSize_; // Width of the wafer
617-
double waferSepar_; // Sensor separation
618-
int sectors_; // Sectors
619-
int cassettes_; // Cassettes
620-
std::string rotstr_; // Rotation matrix (if needed)
621-
std::vector<std::string> waferFull_; // Names of full wafer modules
622-
std::vector<std::string> waferPart_; // Names of partial wafer modules
623-
std::vector<std::string> passiveFull_; // Names of full passive modules
624-
std::vector<std::string> passivePart_; // Names of partial passive modules
625-
std::vector<std::string> materials_; // names of materials
626-
std::vector<std::string> names_; // Names of volumes
627-
std::vector<double> thick_; // Thickness of the material
628-
std::vector<int> copyNumber_; // Initial copy numbers
629-
std::vector<int> layers_; // Number of layers in a section
630-
std::vector<double> layerThick_; // Thickness of each section
631-
std::vector<int> layerType_; // Type of the layer
632-
std::vector<int> layerSense_; // Content of a layer (sensitive?)
633-
std::vector<double> slopeB_; // Slope at the lower R
634-
std::vector<double> zFrontB_; // Starting Z values for the slopes
635-
std::vector<double> rMinFront_; // Corresponding rMin's
636-
std::vector<double> slopeT_; // Slopes at the larger R
637-
std::vector<double> zFrontT_; // Starting Z values for the slopes
638-
std::vector<double> rMaxFront_; // Corresponding rMax's
639-
std::vector<int> layerOrient_; // Layer orientation (Centering, rotations..)
640-
std::vector<int> waferIndex_; // Wafer index for the types
641-
std::vector<int> waferProperty_; // Wafer property
642-
std::vector<int> waferLayerStart_; // Index of wafers in each layer
643-
std::vector<double> cassetteShift_; // Shifts of the cassetes
644-
std::unordered_set<int> copies_; // List of copy #'s
621+
int waferTypes_; // Number of wafer types
622+
int passiveTypes_; // Number of passive types
623+
int facingTypes_; // Types of facings of modules toward IP
624+
int orientationTypes_; // Number of wafer orienations
625+
int partialTypes_; // Number of partial types
626+
int placeOffset_; // Offset for placement
627+
int firstLayer_; // Copy # of the first sensitive layer
628+
int absorbMode_; // Absorber mode
629+
int sensitiveMode_; // Sensitive mode
630+
int passiveMode_; // Mode for passive volumes
631+
double zMinBlock_; // Starting z-value of the block
632+
double waferSize_; // Width of the wafer
633+
double waferSepar_; // Sensor separation
634+
int sectors_; // Sectors
635+
int cassettes_; // Cassettes
636+
std::string rotstr_; // Rotation matrix (if needed)
637+
std::vector<std::string> waferFull_; // Names of full wafer modules
638+
std::vector<std::string> waferPart_; // Names of partial wafer modules
639+
std::vector<std::string> passiveAbsorb_; // Names of full passive modules
640+
std::vector<std::string> passiveCool_; // Names of partial passive modules
641+
std::vector<std::string> materials_; // names of materials
642+
std::vector<std::string> names_; // Names of volumes
643+
std::vector<double> thick_; // Thickness of the material
644+
std::vector<int> copyNumber_; // Initial copy numbers
645+
std::vector<int> layers_; // Number of layers in a section
646+
std::vector<double> layerThick_; // Thickness of each section
647+
std::vector<int> layerType_; // Type of the layer
648+
std::vector<int> layerSense_; // Content of a layer (sensitive?)
649+
std::vector<double> slopeB_; // Slope at the lower R
650+
std::vector<double> zFrontB_; // Starting Z values for the slopes
651+
std::vector<double> rMinFront_; // Corresponding rMin's
652+
std::vector<double> slopeT_; // Slopes at the larger R
653+
std::vector<double> zFrontT_; // Starting Z values for the slopes
654+
std::vector<double> rMaxFront_; // Corresponding rMax's
655+
std::vector<int> layerOrient_; // Layer orientation (Centering, rotations..)
656+
std::vector<int> waferIndex_; // Wafer index for the types
657+
std::vector<int> waferProperty_; // Wafer property
658+
std::vector<int> waferLayerStart_; // Index of wafers in each layer
659+
std::vector<double> cassetteShift_; // Shifts of the cassetes
660+
std::unordered_set<int> copies_; // List of copy #'s
645661
double alpha_, cosAlpha_;
646662
};
647663

0 commit comments

Comments
 (0)