121 : geometryFileName_(iConfig.getParameter<edm::FileInPath>(
"GeometryFileName")) {
122 viewToken_ = esConsumes<DDCompactView, IdealGeometryRecord>();
139 std::stringstream
ss;
140 ss <<
"(" << std::get<0>(coord) <<
"," << std::get<1>(coord) <<
"," << std::get<2>(coord) <<
")";
146 if (walker.
current().first.name().name() == targetName) {
163 if (walker.
current().first.name().fullname().rfind(
"hgcalwafer:", 0) == 0) {
182 if (walker.
current().first.name().fullname().rfind(
"hgcalwafer:", 0) == 0) {
185 const int copyNo = wafer.second->copyno();
190 const WaferCoord waferCoord(waferLayer, waferU, waferV);
194 waferInfo.
x = wafer.second->translation().x();
195 waferInfo.
y = wafer.second->translation().y();
197 std::regex_replace(waferName,
198 std::regex(
"(HGCal[EH]E)(Wafer[01])(Fine|Coarse[12])([a-z]*)([0-9]*)"),
200 std::regex_constants::format_no_copy);
201 std::stringstream
ss(waferNameData);
206 ss >> EEorHE >> typeStr >> shapeStr >> rotStr;
208 if (shapeStr.empty())
212 const int rotCode(std::stoi(rotStr));
216 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferOut;
218 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferFull;
219 else if (shapeStr ==
"a")
220 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferHalf;
221 else if (shapeStr ==
"am")
222 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferHalf2;
223 else if (shapeStr ==
"b")
224 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferFive;
225 else if (shapeStr ==
"bm")
226 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferFive2;
227 else if (shapeStr ==
"c")
228 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferThree;
229 else if (shapeStr ==
"d")
230 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferSemi;
231 else if (shapeStr ==
"dm")
232 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferSemi2;
233 else if (shapeStr ==
"g")
234 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferChopTwo;
235 else if (shapeStr ==
"gm")
236 waferInfo.
shapeCode = HGCalTypes::WaferPartialType::WaferChopTwoM;
253 if (!viewH.isValid()) {
262 auto eeWalker = viewH->walker();
263 const bool eeFound =
DDFindHGCal(eeWalker,
"HGCalEE");
274 auto hesilWalker = viewH->walker();
275 const bool hesilFound =
DDFindHGCal(hesilWalker,
"HGCalHEsil");
286 auto hemixWalker = viewH->walker();
287 const bool hemixFound =
DDFindHGCal(hemixWalker,
"HGCalHEmix");
298 if (!(eeFound || hesilFound || hemixFound)) {
329 int nTotalProcessed = 0;
333 int nThicknessError = 0;
338 int nUnaccounted = 0;
343 while (std::getline(geoTxtFile,
buf)) {
344 std::stringstream
ss(
buf);
345 std::vector<std::string> tokens;
348 tokens.push_back(
buf);
349 if (tokens.size() != 8)
365 if (tokens[2].substr(0, 1) ==
"l" || tokens[2].substr(0, 1) ==
"h") {
367 waferLayer = std::stoi(tokens[0]);
368 waferShapeStr = tokens[1];
369 waferDensityStr = tokens[2].substr(0, 1);
370 waferThickness = std::stoi(tokens[2].substr(1));
371 waferX = std::stod(tokens[3]);
372 waferY = std::stod(tokens[4]);
373 waferRotCode = std::stoi(tokens[5]);
374 waferU = std::stoi(tokens[6]);
375 waferV = std::stoi(tokens[7]);
376 waferShapeCode = HGCalTypes::WaferPartialType::WaferOut;
377 if (waferDensityStr ==
"l") {
378 if (waferShapeStr ==
"0")
379 waferShapeCode = HGCalTypes::WaferPartialType::WaferFull;
380 else if (waferShapeStr ==
"1" || waferShapeStr ==
"2")
381 waferShapeCode = HGCalTypes::WaferPartialType::WaferHalf;
382 else if (waferShapeStr ==
"3" || waferShapeStr ==
"4")
383 waferShapeCode = HGCalTypes::WaferPartialType::WaferSemi;
384 else if (waferShapeStr ==
"5")
385 waferShapeCode = HGCalTypes::WaferPartialType::WaferFive;
386 else if (waferShapeStr ==
"6")
387 waferShapeCode = HGCalTypes::WaferPartialType::WaferThree;
388 }
else if (waferDensityStr ==
"h") {
389 if (waferShapeStr ==
"0")
390 waferShapeCode = HGCalTypes::WaferPartialType::WaferFull;
391 else if (waferShapeStr ==
"1")
392 waferShapeCode = HGCalTypes::WaferPartialType::WaferHalf2;
393 else if (waferShapeStr ==
"2")
394 waferShapeCode = HGCalTypes::WaferPartialType::WaferChopTwoM;
395 else if (waferShapeStr ==
"3" || waferShapeStr ==
"4")
396 waferShapeCode = HGCalTypes::WaferPartialType::WaferSemi2;
397 else if (waferShapeStr ==
"5")
398 waferShapeCode = HGCalTypes::WaferPartialType::WaferFive2;
402 waferLayer = std::stoi(tokens[0]);
403 waferShapeStr = tokens[1];
404 waferThickness = std::stoi(tokens[2]);
405 waferX = std::stod(tokens[3]);
406 waferY = std::stod(tokens[4]);
407 waferRotCode = (std::stoi(tokens[5]));
408 waferU = std::stoi(tokens[6]);
409 waferV = std::stoi(tokens[7]);
410 waferShapeCode = HGCalTypes::WaferPartialType::WaferOut;
411 if (waferShapeStr ==
"F")
412 waferShapeCode = HGCalTypes::WaferPartialType::WaferFull;
413 else if (waferShapeStr ==
"a")
414 waferShapeCode = HGCalTypes::WaferPartialType::WaferHalf;
415 else if (waferShapeStr ==
"am")
416 waferShapeCode = HGCalTypes::WaferPartialType::WaferHalf2;
417 else if (waferShapeStr ==
"b")
418 waferShapeCode = HGCalTypes::WaferPartialType::WaferFive;
419 else if (waferShapeStr ==
"bm")
420 waferShapeCode = HGCalTypes::WaferPartialType::WaferFive2;
421 else if (waferShapeStr ==
"c")
422 waferShapeCode = HGCalTypes::WaferPartialType::WaferThree;
423 else if (waferShapeStr ==
"d")
424 waferShapeCode = HGCalTypes::WaferPartialType::WaferSemi;
425 else if (waferShapeStr ==
"dm")
426 waferShapeCode = HGCalTypes::WaferPartialType::WaferSemi2;
427 else if (waferShapeStr ==
"g")
428 waferShapeCode = HGCalTypes::WaferPartialType::WaferChopTwo;
429 else if (waferShapeStr ==
"gm")
430 waferShapeCode = HGCalTypes::WaferPartialType::WaferChopTwoM;
434 const WaferCoord waferCoord(waferLayer, waferU, waferV);
447 if ((waferInfo.
thickClass == 0 && waferThickness != 120) || (waferInfo.
thickClass == 1 && waferThickness != 200) ||
448 (waferInfo.
thickClass == 2 && waferThickness != 300)) {
454 if (fabs(-waferInfo.
x - waferX) > 0.015) {
459 if (fabs(waferInfo.
y - waferY) > 0.015) {
464 if (waferInfo.
shapeCode != waferShapeCode || waferShapeCode == HGCalTypes::WaferPartialType::WaferOut) {
469 if ((waferShapeCode != HGCalTypes::WaferPartialType::WaferFull && waferInfo.
rotCode != waferRotCode) ||
470 (waferShapeCode == HGCalTypes::WaferPartialType::WaferFull && (waferInfo.
rotCode % 2 != waferRotCode % 2))) {
473 <<
" != " << waferRotCode <<
" )";
481 if (!accounted.second) {
502 if (nMissing > 0 || nThicknessError > 0 || nPosXError > 0 || nPosYError > 0 || nShapeError > 0 || nRotError > 0 ||
524 edm::FileInPath(
"Validation/HGCalValidation/data/geomnew_corrected_360.txt"));
525 descriptions.
add(
"hgcalWaferValidation", desc);
Log< level::Info, true > LogVerbatim
void ProcessWaferLayer(DDCompactView::GraphWalker &walker)
bool DDFindHGCal(DDCompactView::GraphWalker &walker, std::string targetName)
static int32_t getUnpackedU(int id)
int32_t waferU(const int32_t index)
int32_t waferLayer(const int32_t index)
#define DEFINE_FWK_MODULE(type)
static int32_t getUnpackedV(int id)
std::tuple< int, int, int > WaferCoord
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void analyze(const edm::Event &, const edm::EventSetup &) override
static int32_t getUnpackedType(int id)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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 &)
std::map< WaferCoord, struct WaferInfo > waferData
value_type current() const