CMS 3D CMS Logo

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=default
 
- 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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, IdealGeometryRecordviewToken_
 
std::map< WaferCoord, struct WaferInfowaferData_
 
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 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

◆ WaferCoord

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

Definition at line 84 of file HGCalWaferValidation.cc.

◆ WaferShapeMap

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

Definition at line 89 of file HGCalWaferValidation.cc.

Constructor & Destructor Documentation

◆ HGCalWaferValidation()

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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< DDCompactView, IdealGeometryRecord > viewToken_
edm::FileInPath geometryFileName_

◆ ~HGCalWaferValidation()

HGCalWaferValidation::~HGCalWaferValidation ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 297 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, HGCalTypes::WaferOut, waferShapeMapDD, waferShapeMapHD, waferShapeMapLD, HGCalWaferIndex::waferU(), HGCalWaferIndex::waferV(), waferValidated_, HGCalWaferValidation::WaferInfo::x, and HGCalWaferValidation::WaferInfo::y.

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

◆ beginJob()

void HGCalWaferValidation::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 528 of file HGCalWaferValidation.cc.

528  {
529  // please remove this method if not needed
530 }

◆ DDFindHGCal()

bool HGCalWaferValidation::DDFindHGCal ( DDCompactView::GraphWalker walker,
std::string  targetName 
)
private

Definition at line 185 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().

185  {
186  if (walker.current().first.name().name() == targetName) {
187  // target found
188  return true;
189  }
190  if (walker.firstChild()) {
191  do {
192  if (DDFindHGCal(walker, targetName))
193  // target inside child
194  return true;
195  } while (walker.nextSibling());
196  walker.parent();
197  }
198  return false;
199 }
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

◆ DDFindWafers()

void HGCalWaferValidation::DDFindWafers ( DDCompactView::GraphWalker walker)
private

Definition at line 202 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().

202  {
203  if (walker.current().first.name().fullname().rfind("hgcalwafer:", 0) == 0) {
204  // first wafer found. Now process the entire layer of wafers.
205  ProcessWaferLayer(walker);
206  return;
207  }
208  if (walker.firstChild()) {
209  do {
210  DDFindWafers(walker);
211  } while (walker.nextSibling());
212  walker.parent();
213  }
214 }
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

◆ endJob()

void HGCalWaferValidation::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 533 of file HGCalWaferValidation.cc.

533  {
534  // please remove this method if not needed
535 }

◆ fillDescriptions()

void HGCalWaferValidation::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 538 of file HGCalWaferValidation.cc.

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

538  {
539  //The following says we do not know what parameters are allowed so do no validation
540  // Please change this to state exactly what you do use, even if it is no parameters
542  desc.add<edm::FileInPath>("GeometryFileName",
543  edm::FileInPath("Validation/HGCalValidation/data/geomnew_corrected_360.txt"));
544  descriptions.add("hgcalWaferValidation", desc);
545 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ isRotationMatched()

bool HGCalWaferValidation::isRotationMatched ( const bool  isNewFile,
const int  layer,
const int  fileShapeCode,
const int  geoRotCode,
const int  fileRotCode 
)
private

Definition at line 280 of file HGCalWaferValidation.cc.

References nano_mu_digi_cff::layer, layerTypes_, and HGCalTypes::WaferFull.

Referenced by analyze().

281  {
282  if (fileShapeCode != HGCalTypes::WaferFull && geoRotCode == fileRotCode)
283  return true;
284  if (fileShapeCode == HGCalTypes::WaferFull) {
285  if (isNewFile && layerTypes_[layer - 1] == 3) { // this array is index-0 based
286  if ((geoRotCode + 1) % 2 == fileRotCode % 2)
287  return true;
288  } else {
289  if (geoRotCode % 2 == fileRotCode % 2)
290  return true;
291  }
292  }
293  return false;
294 }
static constexpr int32_t WaferFull
Definition: HGCalTypes.h:35
std::vector< int > layerTypes_

◆ isThicknessMatched()

bool HGCalWaferValidation::isThicknessMatched ( const int  geoThickClass,
const int  fileThickness 
)
private

Definition at line 269 of file HGCalWaferValidation.cc.

Referenced by analyze().

269  {
270  if (geoThickClass == 0 && fileThickness == 120)
271  return true;
272  if (geoThickClass == 1 && fileThickness == 200)
273  return true;
274  if (geoThickClass == 2 && fileThickness == 300)
275  return true;
276  return false;
277 }

◆ ProcessWaferLayer()

void HGCalWaferValidation::ProcessWaferLayer ( DDCompactView::GraphWalker walker)
private

Definition at line 217 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().

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

◆ strWaferCoord()

std::string HGCalWaferValidation::strWaferCoord ( const WaferCoord coord)
private

Definition at line 178 of file HGCalWaferValidation.cc.

References contentValuesCheck::ss.

Referenced by analyze().

178  {
179  std::stringstream ss;
180  ss << "(" << std::get<0>(coord) << "," << std::get<1>(coord) << "," << std::get<2>(coord) << ")";
181  return ss.str();
182 }

Member Data Documentation

◆ geometryFileName_

edm::FileInPath HGCalWaferValidation::geometryFileName_
private

Definition at line 130 of file HGCalWaferValidation.cc.

Referenced by analyze().

◆ layerCount_

unsigned int HGCalWaferValidation::layerCount_
private

Definition at line 133 of file HGCalWaferValidation.cc.

Referenced by analyze().

◆ layerTypes_

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

Definition at line 134 of file HGCalWaferValidation.cc.

Referenced by analyze(), and isRotationMatched().

◆ logcat

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

Definition at line 81 of file HGCalWaferValidation.cc.

Referenced by analyze(), and ProcessWaferLayer().

◆ viewToken_

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

Definition at line 147 of file HGCalWaferValidation.cc.

Referenced by analyze(), and HGCalWaferValidation().

◆ waferData_

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

Definition at line 150 of file HGCalWaferValidation.cc.

Referenced by analyze(), and ProcessWaferLayer().

◆ waferShapeMapDD

const WaferShapeMap HGCalWaferValidation::waferShapeMapDD
private

◆ waferShapeMapHD

const WaferShapeMap HGCalWaferValidation::waferShapeMapHD
private
Initial value:

Definition at line 110 of file HGCalWaferValidation.cc.

Referenced by analyze().

◆ waferShapeMapLD

const WaferShapeMap HGCalWaferValidation::waferShapeMapLD
private
Initial value:

Definition at line 102 of file HGCalWaferValidation.cc.

Referenced by analyze().

◆ waferValidated_

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

Definition at line 153 of file HGCalWaferValidation.cc.

Referenced by analyze(), and ProcessWaferLayer().