CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
hcalLUT.cc File Reference
#include <iostream>
#include <stdexcept>
#include <sstream>
#include "TString.h"
#include "PhysicsTools/FWLite/interface/CommandLineParser.h"
#include "CaloOnlineTools/HcalOnlineDb/interface/HcalLutManager.h"
#include "FWCore/Utilities/interface/FileInPath.h"

Go to the source code of this file.

Functions

void dumpLutDiff (LutXml &xmls1, LutXml &xmls2, bool testFormat=true, int detail=0)
 
int main (int argc, char **argv)
 
void mergeLUTs (const char *flist, const char *out)
 

Function Documentation

void dumpLutDiff ( LutXml xmls1,
LutXml xmls2,
bool  testFormat = true,
int  detail = 0 
)

Definition at line 22 of file hcalLUT.cc.

References gather_cfg::cout, ztail::d, LutXml::end(), LutXml::find(), good, mps_fire::i, gpuClustering::id, visualization-live-secondInstance_cfg::m, match(), dqmiodumpmetadata::n, or, findQualityFiles::size, dqmMemoryStats::total, findQualityFiles::v, and SiPixelPI::zero.

Referenced by main().

22  {
23  const int ndet = 5;
24  const char *DET[ndet] = {"HB", "HE", "HO", "HF", "HT"};
25  const int dtype[ndet] = {0, 1, 2, 3, 4};
26 
27  const int nvar = 4;
28  enum vtype { total, extra, zeros, match };
29 
30  std::array<int, nvar> n[ndet];
31 
32  for (auto &d : n) {
33  for (auto &v : d) {
34  v = 0;
35  }
36  }
37 
38  for (auto &x1 : xmls1) {
39  HcalGenericDetId id(x1.first);
40  auto x2 = xmls2.find(id.rawId());
41  auto subdet = id.genericSubdet();
42  if (subdet == 0 or subdet == 6)
43  continue; //'empty' or 'other'
44 
45  auto &m = n[subdet - 1];
46 
47  m[total]++;
48  if (x2 == xmls2.end()) {
49  m[extra]++;
50  if (testFormat)
51  cout << "Extra detId: " << id << endl;
52  else
53  continue;
54  }
55 
56  const auto &lut1 = x1.second;
57  size_t size = lut1.size();
58 
59  bool zero = true;
60  for (auto &i : lut1) {
61  if (i > 0) {
62  zero = false;
63  break;
64  }
65  }
66  if (zero) {
67  m[zeros]++;
68  if (detail == 1 and testFormat) {
69  cout << "Zero LUT: " << id << endl;
70  }
71  }
72 
73  if (testFormat)
74  continue;
75 
76  const auto &lut2 = x2->second;
77  bool good = size == lut2.size();
78  for (size_t i = 0; i < size and good; ++i) {
79  if (lut1[i] != lut2[i]) {
80  good = false;
81  if (detail == 2) {
82  cout << Form("Mismatach in index=%3d, %4d!=%4d, ", int(i), lut1[i], lut2[i]) << id << endl;
83  }
84  }
85  }
86  if (good)
87  m[match]++;
88  }
89 
90  if (testFormat) {
91  cout << Form("%3s: %8s %8s %8s", "Det", "total", "zeroes", "extra") << endl;
92  for (auto i : dtype)
93  cout << Form("%3s: %8d %8d %8d", DET[i], n[i][total], n[i][zeros], n[i][extra]) << endl;
94  cout << "--------------------------------------------" << endl;
95  } else {
96  bool good = true;
97  for (auto &d : n) {
98  if (d[total] != d[match]) {
99  good = false;
100  }
101  }
102  cout << Form("%3s: %8s %8s %8s", "Det", "total", "match", "mismatch") << endl;
103  for (auto i : dtype)
104  cout << Form("%3s: %8d %8d %8d", DET[i], n[i][total], n[i][match], n[i][total] - n[i][match]) << endl;
105  cout << "--------------------------------------------" << endl;
106  cout << (good ? "PASS!" : "FAIL!") << endl;
107  }
108 }
uint16_t *__restrict__ id
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
tuple d
Definition: ztail.py:151
const_iterator find(uint32_t) const
Definition: LutXml.cc:450
auto const good
min quality of good
tuple cout
Definition: gather_cfg.py:144
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
tuple size
Write out results.
const_iterator end() const
Definition: LutXml.cc:448
int main ( int  argc,
char **  argv 
)

Definition at line 110 of file hcalLUT.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, gather_cfg::cout, HcalLutManager::create_lut_loader(), LutXml::create_lut_map(), dumpLutDiff(), submitPVResolutionJobs::files, contentValuesFiles::fullPath, optutl::VariableMapCont::integerValue(), mergeLUTs(), optutl::CommandLineParser::parseArguments(), writedatasetfile::parser, AlCaHLTBitMon_QueryRunRegistry::string, optutl::VariableMapCont::stringValue(), and optutl::VariableMapCont::stringVector().

110  {
111  optutl::CommandLineParser parser("runTestParameters");
112  parser.parseArguments(argc, argv, true);
113  if (argc < 2) {
114  std::cerr << "runTest: missing input command" << std::endl;
115  } else if (strcmp(argv[1], "merge") == 0) {
116  std::string flist_ = parser.stringValue("storePrepend");
117  std::string out_ = parser.stringValue("outputFile");
118  mergeLUTs(flist_.c_str(), out_.c_str());
119  } else if (strcmp(argv[1], "diff") == 0) {
120  auto files = parser.stringVector("inputFiles");
121  auto detail = parser.integerValue("section");
122 
123  LutXml xmls1(edm::FileInPath(files[0]).fullPath());
124  LutXml xmls2(edm::FileInPath(files[1]).fullPath());
125 
126  xmls1.create_lut_map();
127  xmls2.create_lut_map();
128 
129  cout << files[0] << endl;
130  dumpLutDiff(xmls1, xmls2, true, detail);
131 
132  cout << files[1] << endl;
133  dumpLutDiff(xmls2, xmls1, true, detail);
134 
135  cout << "Comparison" << endl;
136  dumpLutDiff(xmls1, xmls2, false, detail);
137  } else if (strcmp(argv[1], "create-lut-loader") == 0) {
138  std::string _file_list = parser.stringValue("outputFile");
139  std::string _tag = parser.stringValue("tag");
140  std::string _comment = parser.stringValue("storePrepend");
141  const std::string &_prefix = _tag;
142  std::string _version = "1";
143  int _subversion = 0;
144  HcalLutManager manager;
145  manager.create_lut_loader(_file_list, _prefix, _tag, _comment, _tag, _subversion);
146  } else {
147  throw std::invalid_argument(Form("Unknown command: %s", argv[1]));
148  }
149 
150  return 0;
151 }
Definition: LutXml.h:27
Various manipulations with trigger Lookup Tables.
int create_lut_loader(std::string file_list, std::string _prefix, std::string tag_name, std::string comment="default comment", std::string version="V00-01-01", int subversion=1)
tuple argc
Definition: dir2webdir.py:39
tuple cout
Definition: gather_cfg.py:144
void dumpLutDiff(LutXml &xmls1, LutXml &xmls2, bool testFormat=true, int detail=0)
Definition: hcalLUT.cc:22
void mergeLUTs(const char *flist, const char *out)
Definition: hcalLUT.cc:11
void mergeLUTs ( const char *  flist,
const char *  out 
)

Definition at line 11 of file hcalLUT.cc.

References mergeVDriftHistosByStation::file, contentValuesCheck::ss, and XMLDOMBlock::write().

Referenced by main().

11  {
12  LutXml xmls;
13  stringstream ss(flist);
14  while (ss.good()) {
15  string file;
16  ss >> file;
17  xmls += LutXml(file);
18  }
19  xmls.write(out);
20 }
Definition: LutXml.h:27
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272