92 {
"a", HGCalTypes::WaferPartialType::WaferHalf},
93 {
"am", HGCalTypes::WaferPartialType::WaferHalf2},
94 {
"b", HGCalTypes::WaferPartialType::WaferFive},
95 {
"bm", HGCalTypes::WaferPartialType::WaferFive2},
96 {
"c", HGCalTypes::WaferPartialType::WaferThree},
97 {
"d", HGCalTypes::WaferPartialType::WaferSemi},
98 {
"dm", HGCalTypes::WaferPartialType::WaferSemi2},
99 {
"g", HGCalTypes::WaferPartialType::WaferChopTwo},
100 {
"gm", HGCalTypes::WaferPartialType::WaferChopTwoM}};
103 {
"1", HGCalTypes::WaferPartialType::WaferHalf},
104 {
"2", HGCalTypes::WaferPartialType::WaferHalf},
105 {
"3", HGCalTypes::WaferPartialType::WaferSemi},
106 {
"4", HGCalTypes::WaferPartialType::WaferSemi},
107 {
"5", HGCalTypes::WaferPartialType::WaferFive},
108 {
"6", HGCalTypes::WaferPartialType::WaferThree}};
111 {
"1", HGCalTypes::WaferPartialType::WaferHalf2},
112 {
"2", HGCalTypes::WaferPartialType::WaferChopTwoM},
113 {
"3", HGCalTypes::WaferPartialType::WaferSemi2},
114 {
"4", HGCalTypes::WaferPartialType::WaferSemi2},
115 {
"5", HGCalTypes::WaferPartialType::WaferFive2}};
122 const bool isNewFile,
const int layer,
const int fileShapeCode,
const int geoRotCode,
const int fileRotCode);
168 : geometryFileName_(iConfig.getParameter<edm::FileInPath>(
"GeometryFileName")) {
169 viewToken_ = esConsumes<DDCompactView, IdealGeometryRecord>();
186 std::stringstream
ss;
187 ss <<
"(" << std::get<0>(coord) <<
"," << std::get<1>(coord) <<
"," << std::get<2>(coord) <<
")";
193 if (walker.
current().first.name().name() == targetName) {
210 if (walker.
current().first.name().fullname().rfind(
"hgcalwafer:", 0) == 0) {
229 if (walker.
current().first.name().fullname().rfind(
"hgcalwafer:", 0) == 0) {
233 const int copyNo = wafer.second->copyno();
238 const WaferCoord waferCoord(waferLayer, waferU, waferV);
243 waferInfo.
x = wafer.second->translation().x();
244 waferInfo.
y = wafer.second->translation().y();
246 std::regex_replace(waferName,
247 std::regex(
"(HGCal[EH]E)(Wafer[01])(Fine|Coarse[12])([a-z]*)([0-9]*)"),
249 std::regex_constants::format_no_copy);
250 std::stringstream
ss(waferNameData);
255 ss >> EEorHE >> typeStr >> shapeStr >> rotStr;
257 if (shapeStr.empty())
261 const int rotCode(std::stoi(rotStr));
277 if (geoThickClass == 0 && fileThickness == 120)
279 if (geoThickClass == 1 && fileThickness == 200)
281 if (geoThickClass == 2 && fileThickness == 300)
288 const bool isNewFile,
const int layer,
const int fileShapeCode,
const int geoRotCode,
const int fileRotCode) {
289 if (fileShapeCode != HGCalTypes::WaferPartialType::WaferFull && geoRotCode == fileRotCode)
291 if (fileShapeCode == HGCalTypes::WaferPartialType::WaferFull) {
293 if ((geoRotCode + 1) % 2 == fileRotCode % 2)
296 if (geoRotCode % 2 == fileRotCode % 2)
310 if (!viewH.isValid()) {
319 auto eeWalker = viewH->walker();
320 const bool eeFound =
DDFindHGCal(eeWalker,
"HGCalEE");
331 auto hesilWalker = viewH->walker();
332 const bool hesilFound =
DDFindHGCal(hesilWalker,
"HGCalHEsil");
343 auto hemixWalker = viewH->walker();
344 const bool hemixFound =
DDFindHGCal(hemixWalker,
"HGCalHEmix");
355 if (!(eeFound || hesilFound || hemixFound)) {
386 int nTotalProcessed = 0;
390 int nThicknessError = 0;
395 int nUnaccounted = 0;
400 std::getline(geoTxtFile,
buf);
401 std::stringstream
ss(
buf);
402 std::vector<std::string> first_tokens;
405 first_tokens.push_back(
buf);
407 const bool isNewFile(first_tokens.size() == 1);
412 std::getline(geoTxtFile,
buf);
413 std::stringstream layerTypesSS(
buf);
414 while (layerTypesSS >>
buf)
433 while (std::getline(geoTxtFile,
buf)) {
434 std::stringstream
ss(
buf);
435 std::vector<std::string> tokens;
438 tokens.push_back(
buf);
439 if (tokens.size() != 8)
447 const std::string waferDensityStr(isNewFile ? tokens[2].substr(0, 1) :
"");
448 const int waferThickness(isNewFile ? std::stoi(tokens[2].substr(1)) : std::stoi(tokens[2]));
449 const double waferX(std::stod(tokens[3]));
450 const double waferY(std::stod(tokens[4]));
451 const int waferRotCode(std::stoi(tokens[5]));
452 const int waferU(std::stoi(tokens[6]));
453 const int waferV(std::stoi(tokens[7]));
454 const int waferShapeCode(isNewFile ? (waferDensityStr ==
"l" ?
waferShapeMapLD.at(waferShapeStr)
456 : HGCalTypes::WaferPartialType::WaferOut)
460 const WaferCoord waferCoord(waferLayer, waferU, waferV);
479 if (fabs(-waferInfo.
x - waferX) > 0.015) {
484 if (fabs(waferInfo.
y - waferY) > 0.015) {
489 if (waferInfo.
shapeCode != waferShapeCode || waferShapeCode == HGCalTypes::WaferPartialType::WaferOut) {
492 <<
" != " << waferDensityStr << waferShapeCode <<
" ) name=" << waferInfo.
waferName;
498 <<
" != " << waferRotCode <<
" (" << waferShapeCode
507 if (!accounted.second) {
528 if (nMissing > 0 || nThicknessError > 0 || nPosXError > 0 || nPosYError > 0 || nShapeError > 0 || nRotError > 0 ||
550 edm::FileInPath(
"Validation/HGCalValidation/data/geomnew_corrected_360.txt"));
551 descriptions.
add(
"hgcalWaferValidation", desc);
std::map< WaferCoord, struct WaferInfo > waferData_
Log< level::Info, true > LogVerbatim
const WaferShapeMap waferShapeMapHD
void ProcessWaferLayer(DDCompactView::GraphWalker &walker)
bool DDFindHGCal(DDCompactView::GraphWalker &walker, std::string targetName)
const WaferShapeMap waferShapeMapDD
static int32_t getUnpackedU(int id)
int32_t waferU(const int32_t index)
std::map< std::string, int > WaferShapeMap
int32_t waferLayer(const int32_t index)
#define DEFINE_FWK_MODULE(type)
static int32_t getUnpackedV(int id)
std::tuple< int, int, int > WaferCoord
constexpr std::array< uint8_t, layerIndexSize > layer
const WaferShapeMap waferShapeMapLD
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< int > layerTypes_
bool isThicknessMatched(const int geoThickClass, const int fileThickness)
static int32_t getUnpackedType(int id)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isRotationMatched(const bool isNewFile, const int layer, const int fileShapeCode, const int geoRotCode, const int fileRotCode)
Log< level::Warning, true > LogPrint
result_type nextSibling()
edm::ESGetToken< DDCompactView, IdealGeometryRecord > viewToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::map< WaferCoord, bool > waferValidated_
~HGCalWaferValidation() override
std::string strWaferCoord(const WaferCoord &coord)
int32_t waferV(const int32_t index)
std::string fullPath() const
edm::FileInPath geometryFileName_
void DDFindWafers(DDCompactView::GraphWalker &walker)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
HGCalWaferValidation(const edm::ParameterSet &)
value_type current() const