CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
HGCalWaferValidation Class Reference

#include <Validation/HGCalValidation/plugins/HGCalWaferValidation.cc>

Inheritance diagram for HGCalWaferValidation:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  WaferInfo
 

Public Member Functions

 HGCalWaferValidation (const edm::ParameterSet &)
 
 ~HGCalWaferValidation () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

using WaferCoord = std::tuple< int, int, int >
 
using WaferShapeMap = std::map< std::string, int >
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
bool DDFindHGCal (DDCompactView::GraphWalker &walker, std::string targetName)
 
void DDFindWafers (DDCompactView::GraphWalker &walker)
 
void endJob () override
 
bool isRotationMatched (const bool isNewFile, const int layer, const int fileShapeCode, const int geoRotCode, const int fileRotCode)
 
bool isThicknessMatched (const int geoThickClass, const int fileThickness)
 
void ProcessWaferLayer (DDCompactView::GraphWalker &walker)
 
std::string strWaferCoord (const WaferCoord &coord)
 

Private Attributes

edm::FileInPath geometryFileName_
 
unsigned int layerCount_
 
std::vector< int > layerTypes_
 
const std::string logcat = "HGCalWaferValidation"
 
edm::ESGetToken< DDCompactView,
IdealGeometryRecord
viewToken_
 
std::map< WaferCoord, struct
WaferInfo
waferData_
 
const WaferShapeMap waferShapeMapDD
 
const WaferShapeMap waferShapeMapHD
 
const WaferShapeMap waferShapeMapLD
 
std::map< WaferCoord, bool > waferValidated_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Validates HGCal wafer data inside DD against specifications given in a flat text file.

Implementation: Uses GraphWalker to follow DD hierarchy to find HGCal EE module and the HE modules. Search of wafer layers and iterates each wafer found. Extract x, y coordinate position from wafer positioning; thickness, u & v coords from copyNo. Wafer shape and rotation are extracted from given names of wafer logical volumes. All extracted wafer info saved into a map indexed by (layer#, u, v). Each line in flat text file are compared against wafer information in the map. Any errors are reported, counted and summarized at the end. Unaccounted wafers, which are in DD but not in the flat text file, are also reported and counted.

Definition at line 72 of file HGCalWaferValidation.cc.

Member Typedef Documentation

using HGCalWaferValidation::WaferCoord = std::tuple<int, int, int>
private

Definition at line 84 of file HGCalWaferValidation.cc.

using HGCalWaferValidation::WaferShapeMap = std::map<std::string, int>
private

Definition at line 89 of file HGCalWaferValidation.cc.

Constructor & Destructor Documentation

HGCalWaferValidation::HGCalWaferValidation ( const edm::ParameterSet iConfig)
explicit

Definition at line 167 of file HGCalWaferValidation.cc.

References viewToken_.

168  : geometryFileName_(iConfig.getParameter<edm::FileInPath>("GeometryFileName")) {
169  viewToken_ = esConsumes<DDCompactView, IdealGeometryRecord>();
170  //now do what ever initialization is needed
171 }
edm::ESGetToken< DDCompactView, IdealGeometryRecord > viewToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::FileInPath geometryFileName_
HGCalWaferValidation::~HGCalWaferValidation ( )
override

Definition at line 173 of file HGCalWaferValidation.cc.

173  {
174  // do anything here that needs to be done at desctruction time
175  // (e.g. close files, deallocate resources etc.)
176  //
177  // please remove this method altogether if it would be left empty
178 }

Member Function Documentation

void HGCalWaferValidation::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 304 of file HGCalWaferValidation.cc.

References visDQMUpload::buf, DDFindHGCal(), DDFindWafers(), MillePedeFileConverter_cfg::fileName, edm::FileInPath::fullPath(), geometryFileName_, edm::EventSetup::getHandle(), mps_fire::i, isRotationMatched(), isThicknessMatched(), layerCount_, layerTypes_, logcat, HGCalWaferValidation::WaferInfo::rotCode, HGCalWaferValidation::WaferInfo::shapeCode, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, strWaferCoord(), HGCalWaferValidation::WaferInfo::thickClass, viewToken_, waferData_, HGCalWaferIndex::waferLayer(), HGCalWaferValidation::WaferInfo::waferName, waferShapeMapDD, waferShapeMapHD, waferShapeMapLD, HGCalWaferIndex::waferU(), HGCalWaferIndex::waferV(), waferValidated_, HGCalWaferValidation::WaferInfo::x, and HGCalWaferValidation::WaferInfo::y.

304  {
305  using namespace edm;
306 
307  // Get the CMS DD
308  auto viewH = iSetup.getHandle(viewToken_);
309 
310  if (!viewH.isValid()) {
311  edm::LogPrint(logcat) << "Error obtaining geometry handle!";
312  return;
313  }
314 
315  edm::LogVerbatim(logcat) << "Root is : " << viewH->root();
316  edm::LogVerbatim(logcat) << std::endl;
317 
318  // find HGCalEE
319  auto eeWalker = viewH->walker();
320  const bool eeFound = DDFindHGCal(eeWalker, "HGCalEE");
321  if (eeFound) {
322  edm::LogVerbatim(logcat) << "HGCalEE found!";
323  edm::LogVerbatim(logcat) << "name = " << eeWalker.current().first.name().name();
324  edm::LogVerbatim(logcat) << "fullname = " << eeWalker.current().first.name().fullname();
325  } else {
326  edm::LogPrint(logcat) << "HGCalEE not found!";
327  }
328  edm::LogVerbatim(logcat) << std::endl;
329 
330  // find HGCalHEsil
331  auto hesilWalker = viewH->walker();
332  const bool hesilFound = DDFindHGCal(hesilWalker, "HGCalHEsil");
333  if (hesilFound) {
334  edm::LogVerbatim(logcat) << "HGCalHEsil found!";
335  edm::LogVerbatim(logcat) << "name = " << hesilWalker.current().first.name().name();
336  edm::LogVerbatim(logcat) << "fullname = " << hesilWalker.current().first.name().fullname();
337  } else {
338  edm::LogPrint(logcat) << "HGCalHEsil not found!";
339  }
340  edm::LogVerbatim(logcat) << std::endl;
341 
342  // find HGCalHEmix
343  auto hemixWalker = viewH->walker();
344  const bool hemixFound = DDFindHGCal(hemixWalker, "HGCalHEmix");
345  if (hemixFound) {
346  edm::LogVerbatim(logcat) << "HGCalHEmix found!";
347  edm::LogVerbatim(logcat) << "name = " << hemixWalker.current().first.name().name();
348  edm::LogVerbatim(logcat) << "fullname = " << hemixWalker.current().first.name().fullname();
349  } else {
350  edm::LogPrint(logcat) << "HGCalHEmix not found!";
351  }
352  edm::LogVerbatim(logcat) << std::endl;
353 
354  // give up if no HGCal found at all
355  if (!(eeFound || hesilFound || hemixFound)) {
356  edm::LogPrint(logcat) << "Nothing found. Giving up.";
357  return;
358  }
359 
360  // Now walk the HGCalEE walker to find the first wafer on each layer and process them
361  edm::LogVerbatim(logcat) << "Calling DDFindWafers(eeWalker);";
362  DDFindWafers(eeWalker);
363 
364  // Walk the HGCalHEsilwalker to find the first wafer on each layer and process them
365  edm::LogVerbatim(logcat) << "Calling DDFindWafers(hesilWalker);";
366  DDFindWafers(hesilWalker);
367 
368  // Walk the HGCalHEmix walker to find the first wafer on each layer and process them
369  edm::LogVerbatim(logcat) << "Calling DDFindWafers(hemixWalker);";
370  DDFindWafers(hemixWalker);
371 
372  // Confirm all the DD wafers have been read
373  edm::LogVerbatim(logcat) << "Number of wafers read from DD: " << waferData_.size();
374 
375  // Now open the geometry text file
377  edm::LogVerbatim(logcat) << "Opening geometry text file: " << fileName;
378  std::ifstream geoTxtFile(fileName);
379 
380  if (!geoTxtFile) {
381  edm::LogPrint(logcat) << "Cannot open geometry text file.";
382  return;
383  }
384 
385  // total processed counter
386  int nTotalProcessed = 0;
387 
388  // geometry error counters
389  int nMissing = 0;
390  int nThicknessError = 0;
391  int nPosXError = 0;
392  int nPosYError = 0;
393  int nShapeError = 0;
394  int nRotError = 0;
395  int nUnaccounted = 0;
396 
398 
399  // find out if this file is an old file or a new file
400  std::getline(geoTxtFile, buf);
401  std::stringstream ss(buf);
402  std::vector<std::string> first_tokens;
403  while (ss >> buf)
404  if (!buf.empty())
405  first_tokens.push_back(buf);
406 
407  const bool isNewFile(first_tokens.size() == 1);
408 
409  if (isNewFile) {
410  edm::LogVerbatim(logcat) << "Text file is of newer version.";
411  layerCount_ = std::stoi(buf);
412  std::getline(geoTxtFile, buf);
413  std::stringstream layerTypesSS(buf);
414  while (layerTypesSS >> buf)
415  if (!buf.empty())
416  layerTypes_.push_back(std::stoi(buf));
417  if (layerTypes_.size() != layerCount_)
418  edm::LogWarning(logcat) << "Number of layer types does not tally with layer count.";
419 
420  // TEMP: make sure reading is correct
421  edm::LogVerbatim(logcat) << "layerCount = " << layerCount_;
422  for (unsigned i = 0; i < layerTypes_.size(); i++) {
423  edm::LogVerbatim(logcat) << " layerType " << i + 1 << " = " << layerTypes_[i]; // 1-based
424  }
425  } else {
426  layerCount_ = 0;
427  // rewind back
428  geoTxtFile.clear();
429  geoTxtFile.seekg(0);
430  }
431 
432  // process each line on the text file
433  while (std::getline(geoTxtFile, buf)) {
434  std::stringstream ss(buf);
435  std::vector<std::string> tokens;
436  while (ss >> buf)
437  if (!buf.empty())
438  tokens.push_back(buf);
439  if (tokens.size() != 8)
440  continue;
441 
442  nTotalProcessed++;
443 
444  // extract wafer info from a textfile line
445  const int waferLayer(std::stoi(tokens[0]));
446  const std::string waferShapeStr(tokens[1]);
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)
455  : waferDensityStr == "h" ? waferShapeMapHD.at(waferShapeStr)
456  : HGCalTypes::WaferPartialType::WaferOut)
457  : waferShapeMapDD.at(waferShapeStr));
458 
459  // map index for crosschecking with DD
460  const WaferCoord waferCoord(waferLayer, waferU, waferV);
461 
462  // now check for (and report) wafer data disagreements
463 
464  if (waferData_.find(waferCoord) == waferData_.end()) {
465  nMissing++;
466  edm::LogVerbatim(logcat) << "MISSING: " << strWaferCoord(waferCoord);
467  continue;
468  }
469 
470  const struct WaferInfo waferInfo = waferData_[waferCoord];
471  waferValidated_[waferCoord] = true;
472 
473  if (!isThicknessMatched(waferInfo.thickClass, waferThickness)) {
474  nThicknessError++;
475  edm::LogVerbatim(logcat) << "THICKNESS ERROR: " << strWaferCoord(waferCoord);
476  }
477 
478  // it seems that wafer x-coords relative to their layer plane are mirrored...
479  if (fabs(-waferInfo.x - waferX) > 0.015) { // assuming this much tolerance
480  nPosXError++;
481  edm::LogVerbatim(logcat) << "POSITION x ERROR: " << strWaferCoord(waferCoord);
482  }
483 
484  if (fabs(waferInfo.y - waferY) > 0.015) { // assuming this much tolerance
485  nPosYError++;
486  edm::LogVerbatim(logcat) << "POSITION y ERROR: " << strWaferCoord(waferCoord);
487  }
488 
489  if (waferInfo.shapeCode != waferShapeCode || waferShapeCode == HGCalTypes::WaferPartialType::WaferOut) {
490  nShapeError++;
491  edm::LogVerbatim(logcat) << "SHAPE ERROR: " << strWaferCoord(waferCoord) << " ( " << waferInfo.shapeCode
492  << " != " << waferDensityStr << waferShapeCode << " ) name=" << waferInfo.waferName;
493  }
494 
495  if (!isRotationMatched(isNewFile, std::get<0>(waferCoord), waferShapeCode, waferInfo.rotCode, waferRotCode)) {
496  nRotError++;
497  edm::LogVerbatim(logcat) << "ROTATION ERROR: " << strWaferCoord(waferCoord) << " ( " << waferInfo.rotCode
498  << " != " << waferRotCode << " (" << waferShapeCode
499  << ") ) name=" << waferInfo.waferName;
500  }
501  }
502 
503  geoTxtFile.close();
504 
505  // Find unaccounted DD wafers
506  for (auto const& accounted : waferValidated_) {
507  if (!accounted.second) {
508  nUnaccounted++;
509  edm::LogVerbatim(logcat) << "UNACCOUNTED: " << strWaferCoord(accounted.first);
510  }
511  }
512 
513  // Print out error counts
514  edm::LogVerbatim(logcat) << std::endl;
515  edm::LogVerbatim(logcat) << "*** ERROR COUNTS ***";
516  edm::LogVerbatim(logcat) << "Missing : " << nMissing;
517  edm::LogVerbatim(logcat) << "Thickness error : " << nThicknessError;
518  edm::LogVerbatim(logcat) << "Pos-x error : " << nPosXError;
519  edm::LogVerbatim(logcat) << "Pos-y error : " << nPosYError;
520  edm::LogVerbatim(logcat) << "Shape error : " << nShapeError;
521  edm::LogVerbatim(logcat) << "Rotation error : " << nRotError;
522  edm::LogVerbatim(logcat) << "Unaccounted : " << nUnaccounted;
523  edm::LogVerbatim(logcat) << std::endl;
524  edm::LogVerbatim(logcat) << "Total wafers processed from geotxtfile = " << nTotalProcessed;
525  edm::LogVerbatim(logcat) << std::endl;
526 
527  // Issue a LogPrint (warning) if there is at least one wafer errors
528  if (nMissing > 0 || nThicknessError > 0 || nPosXError > 0 || nPosYError > 0 || nShapeError > 0 || nRotError > 0 ||
529  nUnaccounted > 0) {
530  edm::LogPrint(logcat) << "There are at least one wafer error.";
531  }
532 }
std::map< WaferCoord, struct WaferInfo > waferData_
Log< level::Info, true > LogVerbatim
const WaferShapeMap waferShapeMapHD
bool DDFindHGCal(DDCompactView::GraphWalker &walker, std::string targetName)
const WaferShapeMap waferShapeMapDD
int32_t waferU(const int32_t index)
int32_t waferLayer(const int32_t index)
const std::string logcat
std::tuple< int, int, int > WaferCoord
const WaferShapeMap waferShapeMapLD
std::vector< int > layerTypes_
bool isThicknessMatched(const int geoThickClass, const int fileThickness)
bool isRotationMatched(const bool isNewFile, const int layer, const int fileShapeCode, const int geoRotCode, const int fileRotCode)
Log< level::Warning, true > LogPrint
edm::ESGetToken< DDCompactView, IdealGeometryRecord > viewToken_
std::map< WaferCoord, bool > waferValidated_
std::string strWaferCoord(const WaferCoord &coord)
int32_t waferV(const int32_t index)
std::string fullPath() const
Definition: FileInPath.cc:161
edm::FileInPath geometryFileName_
void DDFindWafers(DDCompactView::GraphWalker &walker)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
void HGCalWaferValidation::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 535 of file HGCalWaferValidation.cc.

535  {
536  // please remove this method if not needed
537 }
bool HGCalWaferValidation::DDFindHGCal ( DDCompactView::GraphWalker walker,
std::string  targetName 
)
private

Definition at line 192 of file HGCalWaferValidation.cc.

References math::GraphWalker< N, E >::current(), math::GraphWalker< N, E >::firstChild(), math::GraphWalker< N, E >::nextSibling(), and math::GraphWalker< N, E >::parent().

Referenced by analyze().

192  {
193  if (walker.current().first.name().name() == targetName) {
194  // target found
195  return true;
196  }
197  if (walker.firstChild()) {
198  do {
199  if (DDFindHGCal(walker, targetName))
200  // target inside child
201  return true;
202  } while (walker.nextSibling());
203  walker.parent();
204  }
205  return false;
206 }
bool DDFindHGCal(DDCompactView::GraphWalker &walker, std::string targetName)
result_type parent()
Definition: GraphWalker.h:130
result_type firstChild()
Definition: GraphWalker.h:108
result_type nextSibling()
Definition: GraphWalker.h:119
value_type current() const
Definition: GraphWalker.h:86
void HGCalWaferValidation::DDFindWafers ( DDCompactView::GraphWalker walker)
private

Definition at line 209 of file HGCalWaferValidation.cc.

References math::GraphWalker< N, E >::current(), math::GraphWalker< N, E >::firstChild(), math::GraphWalker< N, E >::nextSibling(), math::GraphWalker< N, E >::parent(), and ProcessWaferLayer().

Referenced by analyze().

209  {
210  if (walker.current().first.name().fullname().rfind("hgcalwafer:", 0) == 0) {
211  // first wafer found. Now process the entire layer of wafers.
212  ProcessWaferLayer(walker);
213  return;
214  }
215  if (walker.firstChild()) {
216  do {
217  DDFindWafers(walker);
218  } while (walker.nextSibling());
219  walker.parent();
220  }
221 }
void ProcessWaferLayer(DDCompactView::GraphWalker &walker)
result_type parent()
Definition: GraphWalker.h:130
result_type firstChild()
Definition: GraphWalker.h:108
result_type nextSibling()
Definition: GraphWalker.h:119
void DDFindWafers(DDCompactView::GraphWalker &walker)
value_type current() const
Definition: GraphWalker.h:86
void HGCalWaferValidation::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 540 of file HGCalWaferValidation.cc.

540  {
541  // please remove this method if not needed
542 }
void HGCalWaferValidation::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 545 of file HGCalWaferValidation.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and submitPVResolutionJobs::desc.

545  {
546  //The following says we do not know what parameters are allowed so do no validation
547  // Please change this to state exactly what you do use, even if it is no parameters
549  desc.add<edm::FileInPath>("GeometryFileName",
550  edm::FileInPath("Validation/HGCalValidation/data/geomnew_corrected_360.txt"));
551  descriptions.add("hgcalWaferValidation", desc);
552 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool HGCalWaferValidation::isRotationMatched ( const bool  isNewFile,
const int  layer,
const int  fileShapeCode,
const int  geoRotCode,
const int  fileRotCode 
)
private

Definition at line 287 of file HGCalWaferValidation.cc.

References layerTypes_.

Referenced by analyze().

288  {
289  if (fileShapeCode != HGCalTypes::WaferPartialType::WaferFull && geoRotCode == fileRotCode)
290  return true;
291  if (fileShapeCode == HGCalTypes::WaferPartialType::WaferFull) {
292  if (isNewFile && layerTypes_[layer - 1] == 3) { // this array is index-0 based
293  if ((geoRotCode + 1) % 2 == fileRotCode % 2)
294  return true;
295  } else {
296  if (geoRotCode % 2 == fileRotCode % 2)
297  return true;
298  }
299  }
300  return false;
301 }
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< int > layerTypes_
bool HGCalWaferValidation::isThicknessMatched ( const int  geoThickClass,
const int  fileThickness 
)
private

Definition at line 276 of file HGCalWaferValidation.cc.

Referenced by analyze().

276  {
277  if (geoThickClass == 0 && fileThickness == 120)
278  return true;
279  if (geoThickClass == 1 && fileThickness == 200)
280  return true;
281  if (geoThickClass == 2 && fileThickness == 300)
282  return true;
283  return false;
284 }
void HGCalWaferValidation::ProcessWaferLayer ( DDCompactView::GraphWalker walker)
private

Definition at line 224 of file HGCalWaferValidation.cc.

References math::GraphWalker< N, E >::current(), HGCalTypes::getUnpackedType(), HGCalTypes::getUnpackedU(), HGCalTypes::getUnpackedV(), logcat, math::GraphWalker< N, E >::nextSibling(), HGCalWaferValidation::WaferInfo::rotCode, HGCalWaferValidation::WaferInfo::shapeCode, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, HGCalWaferValidation::WaferInfo::thickClass, waferData_, HGCalWaferIndex::waferLayer(), HGCalWaferValidation::WaferInfo::waferName, waferShapeMapDD, HGCalWaferIndex::waferU(), HGCalWaferIndex::waferV(), waferValidated_, HGCalWaferValidation::WaferInfo::x, and HGCalWaferValidation::WaferInfo::y.

Referenced by DDFindWafers().

224  {
225  static int waferLayer = 0; // layer numbers in DD are assumed to be sequential from 1
226  waferLayer++;
227  edm::LogVerbatim(logcat) << "ProcessWaferLayer: Processing layer " << waferLayer;
228  do {
229  if (walker.current().first.name().fullname().rfind("hgcalwafer:", 0) == 0) {
230  auto wafer = walker.current();
231  const std::string waferName(walker.current().first.name().fullname());
232  //edm::LogVerbatim(logcat) << " " << waferName; // DEBUG: in case wafer name info is needed
233  const int copyNo = wafer.second->copyno();
234  // extract DD layer properties
235  const int waferType = HGCalTypes::getUnpackedType(copyNo);
236  const int waferU = HGCalTypes::getUnpackedU(copyNo);
237  const int waferV = HGCalTypes::getUnpackedV(copyNo);
238  const WaferCoord waferCoord(waferLayer, waferU, waferV); // map index
239  // build struct of DD wafer properties
240  struct WaferInfo waferInfo;
241  waferInfo.waferName = waferName; //TEMPORARY
242  waferInfo.thickClass = waferType;
243  waferInfo.x = wafer.second->translation().x();
244  waferInfo.y = wafer.second->translation().y();
245  const std::string waferNameData =
246  std::regex_replace(waferName,
247  std::regex("(HGCal[EH]E)(Wafer[01])(Fine|Coarse[12])([a-z]*)([0-9]*)"),
248  "$1 $2-$3 $4 $5",
249  std::regex_constants::format_no_copy);
250  std::stringstream ss(waferNameData);
251  std::string EEorHE;
252  std::string typeStr;
253  std::string shapeStr;
254  std::string rotStr;
255  ss >> EEorHE >> typeStr >> shapeStr >> rotStr;
256  // assume rotational symmetry of full-sized wafers
257  if (shapeStr.empty())
258  shapeStr = "F";
259  if (rotStr.empty())
260  rotStr = "0";
261  const int rotCode(std::stoi(rotStr));
262  //edm::LogVerbatim(logcat) << "rotStr " << rotStr << " rotCode " << rotCode;
263 
264  // convert shape code to wafer types defined in HGCalTypes.h
265  waferInfo.shapeCode = waferShapeMapDD.at(shapeStr);
266 
267  waferInfo.rotCode = rotCode;
268  // populate the map
269  waferData_[waferCoord] = waferInfo;
270  waferValidated_[waferCoord] = false;
271  }
272  } while (walker.nextSibling());
273 }
std::map< WaferCoord, struct WaferInfo > waferData_
Log< level::Info, true > LogVerbatim
const WaferShapeMap waferShapeMapDD
static int32_t getUnpackedU(int id)
Definition: HGCalTypes.cc:16
int32_t waferU(const int32_t index)
int32_t waferLayer(const int32_t index)
const std::string logcat
static int32_t getUnpackedV(int id)
Definition: HGCalTypes.cc:22
std::tuple< int, int, int > WaferCoord
static int32_t getUnpackedType(int id)
Definition: HGCalTypes.cc:14
result_type nextSibling()
Definition: GraphWalker.h:119
std::map< WaferCoord, bool > waferValidated_
int32_t waferV(const int32_t index)
value_type current() const
Definition: GraphWalker.h:86
std::string HGCalWaferValidation::strWaferCoord ( const WaferCoord coord)
private

Definition at line 185 of file HGCalWaferValidation.cc.

References contentValuesCheck::ss.

Referenced by analyze().

185  {
186  std::stringstream ss;
187  ss << "(" << std::get<0>(coord) << "," << std::get<1>(coord) << "," << std::get<2>(coord) << ")";
188  return ss.str();
189 }

Member Data Documentation

edm::FileInPath HGCalWaferValidation::geometryFileName_
private

Definition at line 130 of file HGCalWaferValidation.cc.

Referenced by analyze().

unsigned int HGCalWaferValidation::layerCount_
private

Definition at line 133 of file HGCalWaferValidation.cc.

Referenced by analyze().

std::vector<int> HGCalWaferValidation::layerTypes_
private

Definition at line 134 of file HGCalWaferValidation.cc.

Referenced by analyze(), and isRotationMatched().

const std::string HGCalWaferValidation::logcat = "HGCalWaferValidation"
private

Definition at line 81 of file HGCalWaferValidation.cc.

Referenced by analyze(), and ProcessWaferLayer().

edm::ESGetToken<DDCompactView, IdealGeometryRecord> HGCalWaferValidation::viewToken_
private

Definition at line 147 of file HGCalWaferValidation.cc.

Referenced by analyze(), and HGCalWaferValidation().

std::map<WaferCoord, struct WaferInfo> HGCalWaferValidation::waferData_
private

Definition at line 150 of file HGCalWaferValidation.cc.

Referenced by analyze(), and ProcessWaferLayer().

const WaferShapeMap HGCalWaferValidation::waferShapeMapDD
private
Initial value:
= {{"F", HGCalTypes::WaferPartialType::WaferFull},
{"a", HGCalTypes::WaferPartialType::WaferHalf},
{"am", HGCalTypes::WaferPartialType::WaferHalf2},
{"b", HGCalTypes::WaferPartialType::WaferFive},
{"bm", HGCalTypes::WaferPartialType::WaferFive2},
{"c", HGCalTypes::WaferPartialType::WaferThree},
{"d", HGCalTypes::WaferPartialType::WaferSemi},
{"dm", HGCalTypes::WaferPartialType::WaferSemi2},
{"g", HGCalTypes::WaferPartialType::WaferChopTwo},
{"gm", HGCalTypes::WaferPartialType::WaferChopTwoM}}

Definition at line 91 of file HGCalWaferValidation.cc.

Referenced by analyze(), and ProcessWaferLayer().

const WaferShapeMap HGCalWaferValidation::waferShapeMapHD
private
Initial value:
= {{"0", HGCalTypes::WaferPartialType::WaferFull},
{"1", HGCalTypes::WaferPartialType::WaferHalf2},
{"2", HGCalTypes::WaferPartialType::WaferChopTwoM},
{"3", HGCalTypes::WaferPartialType::WaferSemi2},
{"4", HGCalTypes::WaferPartialType::WaferSemi2},
{"5", HGCalTypes::WaferPartialType::WaferFive2}}

Definition at line 110 of file HGCalWaferValidation.cc.

Referenced by analyze().

const WaferShapeMap HGCalWaferValidation::waferShapeMapLD
private
Initial value:
= {{"0", HGCalTypes::WaferPartialType::WaferFull},
{"1", HGCalTypes::WaferPartialType::WaferHalf},
{"2", HGCalTypes::WaferPartialType::WaferHalf},
{"3", HGCalTypes::WaferPartialType::WaferSemi},
{"4", HGCalTypes::WaferPartialType::WaferSemi},
{"5", HGCalTypes::WaferPartialType::WaferFive},
{"6", HGCalTypes::WaferPartialType::WaferThree}}

Definition at line 102 of file HGCalWaferValidation.cc.

Referenced by analyze().

std::map<WaferCoord, bool> HGCalWaferValidation::waferValidated_
private

Definition at line 153 of file HGCalWaferValidation.cc.

Referenced by analyze(), and ProcessWaferLayer().