1 #ifndef DropBoxMetaDataPayloadInspectorHelper_H 2 #define DropBoxMetaDataPayloadInspectorHelper_H 11 #include <fmt/printf.h> 13 #include <boost/tokenizer.hpp> 14 #include <boost/range/adaptor/indexed.hpp> 23 const auto& theParameters =
params.getParameterMap();
24 for (
const auto& [
key,
val] : theParameters) {
25 if (
key.find(
"prep") != std::string::npos) {
27 }
else if (
key.find(
"prod") != std::string::npos) {
29 }
else if (
key.find(
"mult") != std::string::npos) {
49 using recordMap = std::map<std::string, RecordMetaDataInfo>;
52 std::vector<std::string> records;
55 std::inserter(records, records.end()),
56 [](std::pair<std::string, DBoxMetadataHelper::RecordMetaDataInfo> recordSetEntry) ->
std::string {
57 return recordSetEntry.first;
62 inline std::vector<std::string>
set_difference(std::vector<std::string>
const& v1,
63 std::vector<std::string>
const& v2) {
64 std::vector<std::string>
diff;
70 std::vector<std::string>
const& v2) {
71 std::vector<std::string>
common;
87 if (
val.hasMultiMetaData()) {
106 <<
"Target has: " <<
m_Map.size() <<
" records, reference has: " << theRefMap.size() <<
" records";
118 const auto& refval = theRefMap.at(
key);
120 if ((
val.getPrepMetaData()).
compare(refval.getPrepMetaData()) != 0) {
121 edm::LogPrint(
"DropBoxMetadataPIHelper") <<
"found difference in prep metadata!";
125 if ((
val.getProdMetaData()).
compare(refval.getProdMetaData()) != 0) {
126 edm::LogPrint(
"DropBoxMetadataPIHelper") <<
"found difference in prod metadata!";
130 if ((
val.getMultiMetaData()).
compare(refval.getMultiMetaData()) != 0) {
131 edm::LogPrint(
"DropBoxMetadataPIHelper") <<
"found difference in multi metadata!";
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!";
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!";
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();
194 unsigned int mapsize =
m_Map.size();
195 float pitch = 1. / (mapsize * 1.1);
198 std::vector<float> y_x1, y_x2, y_line;
199 std::vector<std::string> s_x1, s_x2, s_x3;
209 s_x1.push_back(
"#scale[1.2]{Key}");
216 for (
const auto& element :
m_Map) {
219 s_x1.push_back(element.first);
221 std::vector<std::string>
output;
224 std::string prepMetaData = element.second.getPrepMetaData();
225 std::string prodMetaData = element.second.getProdMetaData();
231 const std::vector<std::string> pathsPrep =
decompose(prepMetaData);
232 const std::vector<std::string> pathsProd =
decompose(prodMetaData);
234 const int colWidth = 80;
237 output.push_back(toAppend);
239 for (
unsigned int iPath = 0; iPath < pathsPrep.size(); ++iPath) {
242 if (thisString.find(
"userText") == std::string::npos) {
244 if ((toAppend + thisString).length() < colWidth && thisString.find(
"inputTag") != 0) {
245 toAppend += thisString;
248 output.push_back(toAppend);
250 toAppend += thisString;
254 if (iPath == pathsPrep.size() - 1) {
255 output.push_back(toAppend);
260 output.push_back(toAppend);
262 for (
unsigned int iPath = 0; iPath < pathsProd.size(); ++iPath) {
265 if (thisString.find(
"userText") == std::string::npos) {
267 if ((toAppend + thisString).length() < colWidth && thisString.find(
"inputTag") != 0) {
268 toAppend += thisString;
271 output.push_back(toAppend);
273 toAppend += thisString;
277 if (iPath == pathsProd.size() - 1)
278 output.push_back(toAppend);
291 y_line.push_back(y - (pitch / 2.));
294 TCanvas
canvas(
"DropBoxMetaData",
"DropBoxMetaData", 2000,
std::max(y_x1.size(), y_x2.size()) * 40);
299 float newpitch = 1 / (
std::max(y_x1.size(), y_x2.size()) * 1.1);
300 float factor = newpitch / pitch;
301 l.SetTextSize(newpitch - 0.002);
303 for (
unsigned int i = 0;
i < y_x1.size();
i++) {
304 l.DrawLatexNDC(
x1, 1 - (1 - y_x1[
i]) *
factor, s_x1[
i].c_str());
307 for (
unsigned int i = 0;
i < y_x2.size();
i++) {
308 l.DrawLatexNDC(
x2, 1 - (1 - y_x2[
i]) *
factor, s_x2[
i].c_str());
314 TLine
lines[y_line.size()];
316 for (
const auto&
line : y_line) {
318 lines[iL].SetLineWidth(1);
319 lines[iL].SetLineStyle(9);
320 lines[iL].SetLineColor(2);
321 lines[iL].Draw(
"same");
344 unsigned int mapsize = 2 *
m_Map.size();
345 float pitch = 1. / (mapsize * 1.1);
347 std::vector<float> y_x1, y_x2, y_line;
348 std::vector<std::string> s_x1, s_x2, s_x3;
356 s_x1.push_back(
"#scale[1.2]{Key}");
364 s_x2.push_back(
"#scale[1.2]{Reference tag / IOV :" + theRefTag +
" / " + theRefIOV +
"}");
372 const auto& refval = theRefMap.at(
key);
378 std::vector<std::string>
output;
382 std::string refPrepMetaData = refval.getPrepMetaData();
383 std::string refProdMetaData = refval.getProdMetaData();
391 const std::vector<std::string> tarPathsPrep =
decompose(tarPrepMetaData);
392 const std::vector<std::string> refPathsPrep =
decompose(refPrepMetaData);
393 const std::vector<std::string> tarPathsProd =
decompose(tarProdMetaData);
394 const std::vector<std::string> refPathsProd =
decompose(refProdMetaData);
396 bool refAndTarIdentical =
true;
406 if (tmpTar != tmpRef) {
407 refAndTarIdentical =
false;
413 size_t lenAfterPrep =
output.size();
425 if (tmpTar != tmpRef) {
426 refAndTarIdentical =
false;
433 if (refAndTarIdentical) {
435 s_x2.push_back(
"#color[4]{identical}");
447 y_line.push_back(y - (pitch / 2.));
454 for (
const auto& ref : ref_records) {
455 if (
std::find(tar_records.begin(), tar_records.end(), ref) == tar_records.end()) {
460 s_x2.push_back(
"#bf{Only in reference, not in target.}");
461 y_line.push_back(y - (pitch / 2.));
466 for (
const auto& tar : tar_records) {
467 if (
std::find(ref_records.begin(), ref_records.end(), tar) == ref_records.end()) {
472 s_x2.push_back(
"#bf{Only in target, not in reference.}");
473 y_line.push_back(y - (pitch / 2.));
479 TCanvas
canvas(
"DropBoxMetaData",
"DropBoxMetaData", 2000,
std::max(y_x1.size(), y_x2.size()) * 40);
484 float newpitch = 1 / (
std::max(y_x1.size(), y_x2.size()) * 1.1);
485 float factor = newpitch / pitch;
486 l.SetTextSize(newpitch - 0.002);
488 for (
unsigned int i = 0;
i < y_x1.size();
i++) {
489 l.DrawLatexNDC(
x1, 1 - (1 - y_x1[
i]) *
factor, s_x1[
i].c_str());
492 for (
unsigned int i = 0;
i < y_x2.size();
i++) {
493 l.DrawLatexNDC(
x2, 1 - (1 - y_x2[
i]) *
factor, s_x2[
i].c_str());
500 TLine
lines[y_line.size()];
502 for (
const auto&
line : y_line) {
504 lines[iL].SetLineWidth(1);
505 lines[iL].SetLineStyle(9);
506 lines[iL].SetLineColor(2);
507 lines[iL].Draw(
"same");
525 size_t start_pos = 0;
526 while ((start_pos =
str.find(from, start_pos)) != std::string::npos) {
527 str.replace(start_pos, from.length(),
to);
528 start_pos +=
to.length();
541 size_t pos = std::string::npos;
543 while ((
pos =
s.find(toErase)) != std::string::npos) {
545 s.erase(
pos, toErase.length());
553 eraseAllSubStr(myString,
"destinationDatabase: oracle://cms_orcoff_prep/CMS_CONDITIONS, ");
558 myString =
replaceAll(myString,
"destinationTags",
"destinationTags:");
559 myString =
replaceAll(myString,
"inputTag",
"inputTag:");
566 eraseAllSubStr(myString,
"destinationDatabase: oracle://cms_orcon_prod/CMS_CONDITIONS, ");
571 myString =
replaceAll(myString,
"destinationTags",
"destinationTags:");
572 myString =
replaceAll(myString,
"inputTag",
"inputTag:");
585 std::vector<std::string>
result;
586 if (!(
s.size() == 1 &&
s[0] == delimeter_)) {
591 if (delimiterPos == std::string::npos) {
592 result.push_back(
s.substr(previousPos));
595 result.push_back(
s.substr(previousPos, delimiterPos - previousPos));
596 previousPos = delimiterPos + 1;
597 if (
s[previousPos] == space_)
606 std::vector<std::string>&
output,
609 const int color = (
header.find(
"tar") == std::string::npos) ? 2 : 3 ;
610 const int colWidth = 80;
616 for (
unsigned int iPath = 0; iPath < thePaths.size(); ++iPath) {
619 if (thisString.find(
"userText") == std::string::npos) {
621 if ((toAppend + thisString).length() < colWidth && thisString.find(
"inputTag") != 0) {
622 toAppend += thisString;
628 toAppend += thisString;
631 if (iPath == thePaths.size() - 1) {
bool compare(const P &i, const P &j)
std::string to_string(const V &value)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Container::value_type value_type
Log< level::Warning, true > LogPrint