CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DBoxMetadataHelper::DBMetaDataTableDisplay Class Reference

#include <DropBoxMetaDataPayloadInspectorHelper.h>

Public Member Functions

 DBMetaDataTableDisplay (DBoxMetadataHelper::recordMap theMap)
 
void printDiffWithMetadata (const DBoxMetadataHelper::recordMap &theRefMap)
 
void printMetaDatas ()
 
void printOneKey (const DBoxMetadataHelper::RecordMetaDataInfo &oneKey)
 
 ~DBMetaDataTableDisplay ()=default
 

Private Member Functions

std::string cleanJson (std::string str)
 
std::string replaceAll (std::string str, const std::string &from, const std::string &to)
 

Private Attributes

DBoxMetadataHelper::recordMap m_Map
 

Detailed Description

Definition at line 76 of file DropBoxMetaDataPayloadInspectorHelper.h.

Constructor & Destructor Documentation

◆ DBMetaDataTableDisplay()

DBoxMetadataHelper::DBMetaDataTableDisplay::DBMetaDataTableDisplay ( DBoxMetadataHelper::recordMap  theMap)
inline

Definition at line 78 of file DropBoxMetaDataPayloadInspectorHelper.h.

78 : m_Map(theMap) {}

◆ ~DBMetaDataTableDisplay()

DBoxMetadataHelper::DBMetaDataTableDisplay::~DBMetaDataTableDisplay ( )
default

Member Function Documentation

◆ cleanJson()

std::string DBoxMetadataHelper::DBMetaDataTableDisplay::cleanJson ( std::string  str)
inlineprivate

◆ printDiffWithMetadata()

void DBoxMetadataHelper::DBMetaDataTableDisplay::printDiffWithMetadata ( const DBoxMetadataHelper::recordMap theRefMap)
inline

Definition at line 104 of file DropBoxMetaDataPayloadInspectorHelper.h.

References cleanJson(), compare(), change_name::diff, spr::find(), DBoxMetadataHelper::getAllRecords(), crabWrapper::key, m_Map, printOneKey(), DBoxMetadataHelper::set_difference(), DBoxMetadataHelper::set_intersection(), and heppy_batch::val.

104  {
105  edm::LogPrint("DropBoxMetadataPIHelper")
106  << "Target has: " << m_Map.size() << " records, reference has: " << theRefMap.size() << " records";
107 
108  const auto& ref_records = DBoxMetadataHelper::getAllRecords(theRefMap);
109  const auto& tar_records = DBoxMetadataHelper::getAllRecords(m_Map);
110 
111  const auto& diff = DBoxMetadataHelper::set_difference(ref_records, tar_records);
112  const auto& common = DBoxMetadataHelper::set_intersection(ref_records, tar_records);
113 
114  // do first the common parts
115  for (const auto& key : common) {
116  edm::LogPrint("DropBoxMetadataPIHelper") << "key: " << key;
117  const auto& val = m_Map.at(key);
118  const auto& refval = theRefMap.at(key);
119 
120  if ((val.getPrepMetaData()).compare(refval.getPrepMetaData()) != 0) {
121  edm::LogPrint("DropBoxMetadataPIHelper") << "found difference in prep metadata!";
122  edm::LogPrint("DropBoxMetadataPIHelper") << " in target : " << cleanJson(val.getPrepMetaData());
123  edm::LogPrint("DropBoxMetadataPIHelper") << " in reference: " << cleanJson(refval.getPrepMetaData());
124  }
125  if ((val.getProdMetaData()).compare(refval.getProdMetaData()) != 0) {
126  edm::LogPrint("DropBoxMetadataPIHelper") << "found difference in prod metadata!";
127  edm::LogPrint("DropBoxMetadataPIHelper") << " in target : " << cleanJson(val.getProdMetaData());
128  edm::LogPrint("DropBoxMetadataPIHelper") << " in reference: " << cleanJson(refval.getProdMetaData());
129  }
130  if ((val.getMultiMetaData()).compare(refval.getMultiMetaData()) != 0) {
131  edm::LogPrint("DropBoxMetadataPIHelper") << "found difference in multi metadata!";
132  edm::LogPrint("DropBoxMetadataPIHelper") << " in target : " << cleanJson(val.getMultiMetaData());
133  edm::LogPrint("DropBoxMetadataPIHelper") << " in reference: " << cleanJson(refval.getMultiMetaData());
134  }
135  edm::LogPrint("DropBoxMetadataPIHelper") << "\n";
136  }
137 
138  // if interesction is not the union check for extra differences
139  if (!diff.empty()) {
140  // check if the reference has more records than target
141  if (ref_records.size() > tar_records.size()) {
142  for (const auto& ref : ref_records) {
143  if (std::find(tar_records.begin(), tar_records.end(), ref) == tar_records.end()) {
144  const auto& refval = theRefMap.at(ref);
145  edm::LogPrint("DropBoxMetadataPIHelper") << "key: " << ref << " not present in target!";
146  printOneKey(refval);
147  }
148  }
149  }
150  // then check if the target has more records than the reference
151  else if (tar_records.size() > ref_records.size()) {
152  for (const auto& tar : tar_records) {
153  if (std::find(ref_records.begin(), ref_records.end(), tar) == ref_records.end()) {
154  const auto& tarval = m_Map.at(tar);
155  edm::LogPrint("DropBoxMetadataPIHelper") << "key: " << tar << " not present in reference!";
156  printOneKey(tarval);
157  }
158  }
159  }
160  }
161  }
bool compare(const P &i, const P &j)
const std::vector< std::string > getAllRecords(const DBoxMetadataHelper::recordMap &recordSet)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Log< level::Warning, true > LogPrint
Definition: common.py:1
void printOneKey(const DBoxMetadataHelper::RecordMetaDataInfo &oneKey)
std::vector< std::string > set_difference(std::vector< std::string > const &v1, std::vector< std::string > const &v2)
std::vector< std::string > set_intersection(std::vector< std::string > const &v1, std::vector< std::string > const &v2)

◆ printMetaDatas()

void DBoxMetadataHelper::DBMetaDataTableDisplay::printMetaDatas ( )
inline

Definition at line 81 of file DropBoxMetaDataPayloadInspectorHelper.h.

References cleanJson(), crabWrapper::key, m_Map, and heppy_batch::val.

81  {
82  for (const auto& [key, val] : m_Map) {
83  edm::LogPrint("DropBoxMetadataPIHelper") << "key: " << key;
84  edm::LogPrint("DropBoxMetadataPIHelper") << "prep: " << cleanJson(val.getPrepMetaData());
85  edm::LogPrint("DropBoxMetadataPIHelper") << "prod: " << cleanJson(val.getProdMetaData());
86  // check, since it's optional
87  if (val.hasMultiMetaData()) {
88  edm::LogPrint("DropBoxMetadataPIHelper") << "multi: " << cleanJson(val.getMultiMetaData());
89  }
90  edm::LogPrint("DropBoxMetadataPIHelper") << "\n";
91  }
92  }
Log< level::Warning, true > LogPrint

◆ printOneKey()

void DBoxMetadataHelper::DBMetaDataTableDisplay::printOneKey ( const DBoxMetadataHelper::RecordMetaDataInfo oneKey)
inline

Definition at line 94 of file DropBoxMetaDataPayloadInspectorHelper.h.

References cleanJson(), DBoxMetadataHelper::RecordMetaDataInfo::getMultiMetaData(), DBoxMetadataHelper::RecordMetaDataInfo::getPrepMetaData(), DBoxMetadataHelper::RecordMetaDataInfo::getProdMetaData(), and DBoxMetadataHelper::RecordMetaDataInfo::hasMultiMetaData().

Referenced by printDiffWithMetadata().

94  {
95  edm::LogPrint("DropBoxMetadataPIHelper") << "prep: " << cleanJson(oneKey.getPrepMetaData());
96  edm::LogPrint("DropBoxMetadataPIHelper") << "prod: " << cleanJson(oneKey.getProdMetaData());
97  // check, since it's optional
98  if (oneKey.hasMultiMetaData()) {
99  edm::LogPrint("DropBoxMetadataPIHelper") << "multi: " << cleanJson(oneKey.getMultiMetaData());
100  }
101  edm::LogPrint("DropBoxMetadataPIHelper") << "\n";
102  }
Log< level::Warning, true > LogPrint

◆ replaceAll()

std::string DBoxMetadataHelper::DBMetaDataTableDisplay::replaceAll ( std::string  str,
const std::string &  from,
const std::string &  to 
)
inlineprivate

Definition at line 166 of file DropBoxMetaDataPayloadInspectorHelper.h.

References str.

Referenced by cleanJson().

166  {
167  size_t start_pos = 0;
168  while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
169  str.replace(start_pos, from.length(), to);
170  start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
171  }
172  return str;
173  }
#define str(s)

Member Data Documentation

◆ m_Map

DBoxMetadataHelper::recordMap DBoxMetadataHelper::DBMetaDataTableDisplay::m_Map
private