Skip to content

Commit eb92ec5

Browse files
author
Sunanda
committed
Update the dd4hep vrsions of V19 algorithmms of HGCal geometry
1 parent 54a31a8 commit eb92ec5

File tree

2 files changed

+62
-40
lines changed

2 files changed

+62
-40
lines changed

Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalMixRotatedFineCassette.cc

Lines changed: 17 additions & 5 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,18 @@ struct HGCalMixRotatedFineCassette {
369373
edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << cms::convert2mm(pgonZ[k]) << " R "
370374
<< cms::convert2mm(pgonRin[k]) << ":" << cms::convert2mm(pgonRout[k]);
371375
#endif
372-
} 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_);
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+
}
385+
} else {
386+
double rins = (sensitiveMode_ < 1) ? rinB : HGCalGeomTools::radius(zz + hthick, zFrontB_, rMinFront_, slopeB_);
387+
double routs = (sensitiveMode_ < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_);
376388
dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2._pi);
377389
ns.addSolidNS(ns.prepend(name), solid);
378390
glog = dd4hep::Volume(solid.name(), solid, matter);

Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalSiliconRotatedCassette.cc

Lines changed: 45 additions & 35 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,9 @@ 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 << ":" << laymax << " zi " << cms::convert2mm(zi);
235+
#endif
229236
for (int ly = laymin; ly < laymax; ++ly) {
230237
int ii = layerType_[ly];
231238
int copy = copyNumber_[ii];
@@ -297,7 +304,10 @@ struct HGCalSiliconRotatedCassette {
297304
if (layerSense_[ly] > 0) {
298305
positionSensitive(ctxt, e, glog, (copy - firstLayer_));
299306
} else if (passiveMode_ > 0) {
300-
positionPassive2(ctxt, e, glog, (copy - firstLayer_), -layerSense_[ly]);
307+
unsigned int num = (-layerSense_[ly] <= waferTypes_) ? passiveAbsorb_.size() : passiveCool_.size();
308+
if (num > 0)
309+
positionPassiveNew(ctxt, e, glog, i, -layerSense_[ly]);
310+
// positionPassiveNew(ctxt, e, glog, (copy - firstLayer_), -layerSense_[ly]);
301311
} else {
302312
positionPassive(ctxt, e, glog, (copy - firstLayer_), -layerSense_[ly]);
303313
}
@@ -510,7 +520,7 @@ struct HGCalSiliconRotatedCassette {
510520
int i(999);
511521
if (part == HGCalTypes::WaferFull) {
512522
i = absType - 1;
513-
passive = passiveFull_[i];
523+
passive = passiveAbsorb_[i];
514524
#ifdef EDM_ML_DEBUG
515525
edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:offsets:ind " << layertype << ":"
516526
<< absType << ":" << part << ":" << orien << ":" << cassette << ":"
@@ -527,9 +537,9 @@ struct HGCalSiliconRotatedCassette {
527537
edm::LogVerbatim("HGCalGeom") << " layertype:abstype:part:orien:cassette:3Types:offset:ind " << layertype << ":"
528538
<< absType << ":" << part << ":" << orien << ":" << cassette << ":"
529539
<< partialTypes_ << ":" << facingTypes_ << ":" << orientationTypes_ << ":"
530-
<< partoffset << ":" << i << ":" << passivePart_.size();
540+
<< partoffset << ":" << i << ":" << passiveCool_.size();
531541
#endif
532-
passive = passivePart_[i];
542+
passive = passiveCool_[i];
533543
}
534544
int copy = HGCalTypes::packTypeUV(absType, u, v);
535545
#ifdef EDM_ML_DEBUG
@@ -560,37 +570,37 @@ struct HGCalSiliconRotatedCassette {
560570
}
561571

562572
// Position the passive modules (mode > 0)
563-
void positionPassive2(cms::DDParsingContext& ctxt, xml_h e, const dd4hep::Volume& glog, int layer, int absType) {
573+
void positionPassiveNew(cms::DDParsingContext& ctxt, xml_h e, const dd4hep::Volume& glog, int layer, int absType) {
564574
cms::DDNamespace ns(ctxt, e, true);
565575
#ifdef EDM_ML_DEBUG
566-
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: positionPassive2 is called";
576+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: positionPassiveNew is called";
567577
int kount(0);
578+
#endif
579+
bool type = (absType <= waferTypes_);
580+
int num = type ? (passiveAbsorb_.size() / (cassettes_ * layers_.size()))
581+
: (passiveCool_.size() / (cassettes_ * layers_.size()));
582+
#ifdef EDM_ML_DEBUG
583+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: Type " << type << " number per cassette " << num;
568584
#endif
569585
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;
586+
double xpos(0), ypos(0);
587+
for (int n = 0; n < num; ++n) {
588+
int i1 = num * k + n;
589+
int i2 = num * layer * cassettes_ + i1;
575590
#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();
591+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive2: layer " << layer + 1 << " cassette " << " PassiveIndex " << i1 << ":" << i2 << ":" << passiveAbsorb_.size() << ":" << passiveCool_.size();
580592
#endif
581-
std::string passive = (absType <= waferTypes_) ? passiveFull_[i] : passivePart_[i];
593+
std::string passive = (type) ? passiveAbsorb_[i2] : passiveCool_[i2];
582594
#ifdef EDM_ML_DEBUG
583-
edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: Passive2 " << passive << " number " << cassette
584-
<< " pos " << cms::convert2mm(xpos) << ":" << cms::convert2mm(ypos);
585-
kount++;
595+
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette::Passive2 " << passive << " number " << i2 << " pos " << cms::convert2mm(xpos) << ":" << cms::convert2mm(ypos) << ":0";
596+
kount++;
586597
#endif
587-
dd4hep::Position tran(xpos, ypos, 0.0);
588-
glog.placeVolume(ns.volume(passive), cassette, tran);
598+
dd4hep::Position tran(xpos, ypos, 0.0);
599+
glog.placeVolume(ns.volume(passive), i2, tran);
589600
#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";
601+
edm::LogVerbatim("HGCalGeom") << " DDHGCalSiliconRotatedCassette: " << passive << " number " << i2 << " positioned in " << glog.name() << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos) << ",0) with no rotation";
593602
#endif
603+
}
594604
}
595605
#ifdef EDM_ML_DEBUG
596606
edm::LogVerbatim("HGCalGeom") << "DDHGCalSiliconRotatedCassette: " << kount << " passives of type " << absType
@@ -620,8 +630,8 @@ struct HGCalSiliconRotatedCassette {
620630
std::string rotstr_; // Rotation matrix (if needed)
621631
std::vector<std::string> waferFull_; // Names of full wafer modules
622632
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
633+
std::vector<std::string> passiveAbsorb_;// Names of full passive modules
634+
std::vector<std::string> passiveCool_; // Names of partial passive modules
625635
std::vector<std::string> materials_; // names of materials
626636
std::vector<std::string> names_; // Names of volumes
627637
std::vector<double> thick_; // Thickness of the material

0 commit comments

Comments
 (0)