Skip to content

Commit

Permalink
Code check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Apr 1, 2020
1 parent 67c781f commit 425804e
Showing 1 changed file with 51 additions and 39 deletions.
90 changes: 51 additions & 39 deletions Geometry/HGCalCommonData/src/HGCalGeomParameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv,
int cell = cellx % 1000;
int type = cellx / 1000;
if (type != 1 && type != 2) {
throw cms::Exception("DDException") << "Funny cell # " << cell << " type " << type << " in " << nsiz << " components";
throw cms::Exception("DDException")
<< "Funny cell # " << cell << " type " << type << " in " << nsiz << " components";
} else {
auto ktr = wafertype.find(wafer);
if (ktr == wafertype.end())
Expand All @@ -241,10 +242,12 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv,
xx += (HGCalParameters::k_ScaleFromDDD * (p2.X()));
yy += (HGCalParameters::k_ScaleFromDDD * (p2.Y()));
#ifdef EDM_ML_DEBUG
if (std::abs(p2.X()) < 1.0e-12) p2.SetX(0.0);
if (std::abs(p2.Z()) < 1.0e-12) p2.SetZ(0.0);
edm::LogVerbatim("HGCalGeom")
<< "Wafer " << wafer << " Type " << type << " Cell " << cellx << " local " << xx << ":" << yy << " new " << p1 << ":" << p2;
if (std::abs(p2.X()) < 1.0e-12)
p2.SetX(0.0);
if (std::abs(p2.Z()) < 1.0e-12)
p2.SetZ(0.0);
edm::LogVerbatim("HGCalGeom") << "Wafer " << wafer << " Type " << type << " Cell " << cellx << " local "
<< xx << ":" << yy << " new " << p1 << ":" << p2;
#endif
}
HGCalGeomParameters::cellParameters cp(half, wafer, GlobalPoint(xx, yy, 0));
Expand Down Expand Up @@ -274,7 +277,7 @@ void HGCalGeomParameters::loadGeometryHexagon(const cms::DDCompactView* cpv,
std::map<int, HGCalGeomParameters::layerParameters> layers;
std::vector<HGCalParameters::hgtrform> trforms;
std::vector<bool> trformUse;
std::vector<std::pair<int,int> > trused;
std::vector<std::pair<int, int> > trused;

while (fv.firstChild()) {
const std::vector<double>& pars = fv.parameters();
Expand Down Expand Up @@ -305,30 +308,30 @@ void HGCalGeomParameters::loadGeometryHexagon(const cms::DDCompactView* cpv,
HGCalGeomParameters::layerParameters laypar(rin, rout, zz);
layers[lay] = laypar;
}
std::pair<int,int> layz(lay, zp);
std::pair<int, int> layz(lay, zp);
if (std::find(trused.begin(), trused.end(), layz) == trused.end()) {
trused.emplace_back(layz);
DD3Vector x, y, z;
fv.rotation().GetComponents(x, y, z);
const CLHEP::HepRep3x3 rotation(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z());
const CLHEP::HepRotation hr(rotation);
double xx = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().X();
if (std::abs(xx) < tolerance)
xx = 0;
double yy = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Y();
if (std::abs(yy) < tolerance)
yy = 0;
double zz = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Z();
const CLHEP::Hep3Vector h3v(xx, yy, zz);
HGCalParameters::hgtrform mytrf;
mytrf.zp = zp;
mytrf.lay = lay;
mytrf.sec = 0;
mytrf.subsec = 0;
mytrf.h3v = h3v;
mytrf.hr = hr;
trforms.emplace_back(mytrf);
trformUse.emplace_back(false);
trused.emplace_back(layz);
DD3Vector x, y, z;
fv.rotation().GetComponents(x, y, z);
const CLHEP::HepRep3x3 rotation(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z());
const CLHEP::HepRotation hr(rotation);
double xx = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().X();
if (std::abs(xx) < tolerance)
xx = 0;
double yy = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Y();
if (std::abs(yy) < tolerance)
yy = 0;
double zz = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Z();
const CLHEP::Hep3Vector h3v(xx, yy, zz);
HGCalParameters::hgtrform mytrf;
mytrf.zp = zp;
mytrf.lay = lay;
mytrf.sec = 0;
mytrf.subsec = 0;
mytrf.h3v = h3v;
mytrf.hr = hr;
trforms.emplace_back(mytrf);
trformUse.emplace_back(false);
}
}
}
Expand Down Expand Up @@ -434,7 +437,8 @@ void HGCalGeomParameters::loadGeometryHexagon(const cms::DDCompactView* cpv,
int cell = cellx % 1000;
int type = cellx / 1000;
if (type != 1 && type != 2) {
throw cms::Exception("DDException") << "Funny cell # " << cell << " type " << type << " in " << nsiz << " components";
throw cms::Exception("DDException")
<< "Funny cell # " << cell << " type " << type << " in " << nsiz << " components";
} else {
auto ktr = wafertype.find(wafer);
if (ktr == wafertype.end())
Expand All @@ -460,10 +464,12 @@ void HGCalGeomParameters::loadGeometryHexagon(const cms::DDCompactView* cpv,
xx += (HGCalParameters::k_ScaleFromDDD * (p2.X()));
yy += (HGCalParameters::k_ScaleFromDDD * (p2.Y()));
#ifdef EDM_ML_DEBUG
if (std::abs(p2.X()) < 1.0e-12) p2.SetX(0.0);
if (std::abs(p2.Z()) < 1.0e-12) p2.SetZ(0.0);
edm::LogVerbatim("HGCalGeom")
<< "Wafer " << wafer << " Type " << type << " Cell " << cellx << " local " << xx << ":" << yy << " new " << p1 << ":" << p2;
if (std::abs(p2.X()) < 1.0e-12)
p2.SetX(0.0);
if (std::abs(p2.Z()) < 1.0e-12)
p2.SetZ(0.0);
edm::LogVerbatim("HGCalGeom") << "Wafer " << wafer << " Type " << type << " Cell " << cellx << " local "
<< xx << ":" << yy << " new " << p1 << ":" << p2;
#endif
}
HGCalGeomParameters::cellParameters cp(half, wafer, GlobalPoint(xx, yy, 0));
Expand Down Expand Up @@ -697,7 +703,8 @@ void HGCalGeomParameters::loadGeometryHexagon8(const DDFilteredView& _fv, HGCalP
<< " lay " << lay << " z " << zside;
#endif
if (lay == 0) {
throw cms::Exception("DDException") << "Funny layer # " << lay << " zp " << zside << " in " << nsiz << " components";
throw cms::Exception("DDException")
<< "Funny layer # " << lay << " zp " << zside << " in " << nsiz << " components";
} else {
if (std::find(php.layer_.begin(), php.layer_.end(), lay) == php.layer_.end())
php.layer_.emplace_back(lay);
Expand Down Expand Up @@ -771,7 +778,8 @@ void HGCalGeomParameters::loadGeometryHexagon8(const cms::DDCompactView* cpv,
<< php.levelZSide_;
#endif
if (lay == 0) {
throw cms::Exception("DDException") << "Funny layer # " << lay << " zp " << zside << " in " << nsiz << " components";
throw cms::Exception("DDException")
<< "Funny layer # " << lay << " zp " << zside << " in " << nsiz << " components";
} else {
if (std::find(php.layer_.begin(), php.layer_.end(), lay) == php.layer_.end())
php.layer_.emplace_back(lay);
Expand Down Expand Up @@ -931,7 +939,8 @@ void HGCalGeomParameters::loadSpecParsHexagon(const cms::DDFilteredView& fv,
php.layerGroupM_ = dbl_to_int(fv.get<std::vector<double> >(sdTag1, "GroupingZMid"));
php.layerGroupO_ = dbl_to_int(fv.get<std::vector<double> >(sdTag1, "GroupingZOut"));
php.slopeMin_ = fv.get<std::vector<double> >(sdTag4, "Slope");
if (php.slopeMin_.empty()) php.slopeMin_.emplace_back(0);
if (php.slopeMin_.empty())
php.slopeMin_.emplace_back(0);

// Wafer size
const auto& dummy = fv.get<std::vector<double> >(sdTag2, "WaferSize");
Expand Down Expand Up @@ -1658,11 +1667,14 @@ std::vector<double> HGCalGeomParameters::getDDDArray(const std::string& str, con
int nval = fvec.size();
if (nmin > 0) {
if (nval < nmin) {
throw cms::Exception("DDException") << "HGCalGeomParameters: # of " << str << " bins " << nval << " < " << nmin << " ==> illegal";
throw cms::Exception("DDException")
<< "HGCalGeomParameters: # of " << str << " bins " << nval << " < " << nmin << " ==> illegal";
}
} else {
if (nval < 1 && nmin == 0) {
throw cms::Exception("DDException") << "HGCalGeomParameters: # of " << str << " bins " << nval << " < 1 ==> illegal" << " (nmin=" << nmin << ")";
throw cms::Exception("DDException")
<< "HGCalGeomParameters: # of " << str << " bins " << nval << " < 1 ==> illegal"
<< " (nmin=" << nmin << ")";
}
}
return fvec;
Expand Down

0 comments on commit 425804e

Please sign in to comment.