Skip to content

Commit

Permalink
Code check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Jun 13, 2022
1 parent 87cc318 commit 6dbb55d
Showing 1 changed file with 71 additions and 45 deletions.
116 changes: 71 additions & 45 deletions Geometry/HGCalCommonData/test/HGCalPartialWaferTester.cc
Expand Up @@ -44,13 +44,29 @@ HGCalPartialWaferTester::HGCalPartialWaferTester(const edm::ParameterSet& iC)
partialTypes_(iC.getParameter<std::vector<int>>("partialTypes")),
nTrials_(iC.getParameter<int>("numberOfTrials")),
dddToken_(esConsumes<HGCalDDDConstants, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_})) {
edm::LogVerbatim("HGCalGeom") << "Test positions for " << partialTypes_.size() << " partial wafer types " << " and " << orientations_.size() << " Orientations for " << nameSense_;
edm::LogVerbatim("HGCalGeom") << "Test positions for " << partialTypes_.size() << " partial wafer types "
<< " and " << orientations_.size() << " Orientations for " << nameSense_;
}

void HGCalPartialWaferTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
std::vector<int> orients = {HGCalTypes::WaferOrient0, HGCalTypes::WaferOrient1, HGCalTypes::WaferOrient2, HGCalTypes::WaferOrient3, HGCalTypes::WaferOrient4, HGCalTypes::WaferOrient5};
std::vector<int> types = {HGCalTypes::WaferLDTop, HGCalTypes::WaferLDBottom, HGCalTypes::WaferLDLeft, HGCalTypes::WaferLDRight, HGCalTypes::WaferLDFive, HGCalTypes::WaferLDThree, HGCalTypes::WaferHDTop, HGCalTypes::WaferHDBottom, HGCalTypes::WaferHDLeft, HGCalTypes::WaferHDRight, HGCalTypes::WaferHDFive};
std::vector<int> orients = {HGCalTypes::WaferOrient0,
HGCalTypes::WaferOrient1,
HGCalTypes::WaferOrient2,
HGCalTypes::WaferOrient3,
HGCalTypes::WaferOrient4,
HGCalTypes::WaferOrient5};
std::vector<int> types = {HGCalTypes::WaferLDTop,
HGCalTypes::WaferLDBottom,
HGCalTypes::WaferLDLeft,
HGCalTypes::WaferLDRight,
HGCalTypes::WaferLDFive,
HGCalTypes::WaferLDThree,
HGCalTypes::WaferHDTop,
HGCalTypes::WaferHDBottom,
HGCalTypes::WaferHDLeft,
HGCalTypes::WaferHDRight,
HGCalTypes::WaferHDFive};
desc.add<std::string>("nameSense", "HGCalHESiliconSensitive");
desc.add<std::vector<int>>("waferOrientations", orients);
desc.add<std::vector<int>>("partialTypes", types);
Expand All @@ -64,52 +80,62 @@ void HGCalPartialWaferTester::analyze(const edm::Event&, const edm::EventSetup&
for (const auto& partialType : partialTypes_) {
for (const auto& orientation : orientations_) {
int indx(-1), type(-1);
for (auto itr = hgdc.getParameter()->waferInfoMap_.begin(); itr != hgdc.getParameter()->waferInfoMap_.end(); ++itr) {
if (((itr->second).part == partialType) && ((itr->second).orient == orientation)) {
indx = itr->first;
type = (itr->second).type;
break;
}
for (auto itr = hgdc.getParameter()->waferInfoMap_.begin(); itr != hgdc.getParameter()->waferInfoMap_.end();
++itr) {
if (((itr->second).part == partialType) && ((itr->second).orient == orientation)) {
indx = itr->first;
type = (itr->second).type;
break;
}
}

if (indx > 0) {
int alltry(0), error(0);
int layer = HGCalWaferIndex::waferLayer(indx);
int waferU = HGCalWaferIndex::waferU(indx);
int waferV = HGCalWaferIndex::waferV(indx);
auto xy = hgdc.waferPosition(layer, waferU, waferV, true, false);
edm::LogVerbatim("HGCalGeom") << "\n\nPartial Type " << partialType << " Orientation " << orientation << " Wafer " << waferU << ":" << waferV << " in layer " << layer << " at " << xy.first << ":" << xy.second << "\n\n";
int nCells = (type == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN;
for (int i = 0; i < nTrials_; i++) {
int ui = std::floor(2 * nCells * rand() / RAND_MAX);
int vi = std::floor(2 * nCells * rand() / RAND_MAX);
if ((ui < 2 * nCells) && (vi < 2 * nCells) && ((vi - ui) < nCells) && ((ui - vi) <= nCells) &&
HGCalWaferMask::goodCell(ui, vi, partialType)) {
++alltry;
auto xy = hgdc.locateCell(layer, waferU, waferV, ui, vi, reco, all, norot, debug1);
int lay(layer), cU(0), cV(0), wType(-1), wU(0), wV(0);
double wt(0);
hgdc.waferFromPosition(HGCalParameters::k_ScaleToDDD * xy.first,
HGCalParameters::k_ScaleToDDD * xy.second,
lay,
wU,
wV,
cU,
cV,
wType,
wt,
extend,
debug2);
bool ok = ((wType == type) && (layer == lay) && (waferU == wU) && (waferV == wV) && (ui == cU) && (vi == cV));
std::string comment = (ok) ? "" : " ***** ERROR *****";
edm::LogVerbatim("HGCalGeom") << "Layer " << layer << ":" << lay << " waferU " << waferU << ":" << wU << " waferV " << waferV << ":" << wV << " Type " << type << ":" << wType << " cellU " << ui << ":" << cU << " cellV " << vi << ":" << cV << " position " << xy.first << ":" << xy.second << comment;
if (!ok)
++error;
}
}
edm::LogVerbatim("HGCalGeom") << "\n\nFound " << error << " errors among " << alltry << ":" << nTrials_ << " trials for partial type " << partialType << " orientation " << orientation << " of " << nameSense_;
int alltry(0), error(0);
int layer = HGCalWaferIndex::waferLayer(indx);
int waferU = HGCalWaferIndex::waferU(indx);
int waferV = HGCalWaferIndex::waferV(indx);
auto xy = hgdc.waferPosition(layer, waferU, waferV, true, false);
edm::LogVerbatim("HGCalGeom") << "\n\nPartial Type " << partialType << " Orientation " << orientation
<< " Wafer " << waferU << ":" << waferV << " in layer " << layer << " at "
<< xy.first << ":" << xy.second << "\n\n";
int nCells = (type == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN;
for (int i = 0; i < nTrials_; i++) {
int ui = std::floor(2 * nCells * rand() / RAND_MAX);
int vi = std::floor(2 * nCells * rand() / RAND_MAX);
if ((ui < 2 * nCells) && (vi < 2 * nCells) && ((vi - ui) < nCells) && ((ui - vi) <= nCells) &&
HGCalWaferMask::goodCell(ui, vi, partialType)) {
++alltry;
auto xy = hgdc.locateCell(layer, waferU, waferV, ui, vi, reco, all, norot, debug1);
int lay(layer), cU(0), cV(0), wType(-1), wU(0), wV(0);
double wt(0);
hgdc.waferFromPosition(HGCalParameters::k_ScaleToDDD * xy.first,
HGCalParameters::k_ScaleToDDD * xy.second,
lay,
wU,
wV,
cU,
cV,
wType,
wt,
extend,
debug2);
bool ok =
((wType == type) && (layer == lay) && (waferU == wU) && (waferV == wV) && (ui == cU) && (vi == cV));
std::string comment = (ok) ? "" : " ***** ERROR *****";
edm::LogVerbatim("HGCalGeom")
<< "Layer " << layer << ":" << lay << " waferU " << waferU << ":" << wU << " waferV " << waferV << ":"
<< wV << " Type " << type << ":" << wType << " cellU " << ui << ":" << cU << " cellV " << vi << ":"
<< cV << " position " << xy.first << ":" << xy.second << comment;
if (!ok)
++error;
}
}
edm::LogVerbatim("HGCalGeom") << "\n\nFound " << error << " errors among " << alltry << ":" << nTrials_
<< " trials for partial type " << partialType << " orientation " << orientation
<< " of " << nameSense_;
} else {
edm::LogVerbatim("HGCalGeom") << "\n\nCannot find a wafer of type " << partialType << " and orientation " << orientation << " for " << nameSense_;
edm::LogVerbatim("HGCalGeom") << "\n\nCannot find a wafer of type " << partialType << " and orientation "
<< orientation << " for " << nameSense_;
}
}
}
Expand Down

0 comments on commit 6dbb55d

Please sign in to comment.