CMS 3D CMS Logo

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

◆ dumpLutDiff()

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, runTauDisplay::dtype, LutXml::end(), LutXml::find(), caHitNtupletGeneratorKernels::good, mps_fire::i, l1ctLayer2EG_cff::id, visualization-live-secondInstance_cfg::m, dqmiodumpmetadata::n, or, nano_mu_digi_cff::rawId, 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  const int HBandHE_fgBits = 0xFC00;
27 
28  const int nvar = 5;
29  enum vtype { total, extra, zeros, match, fgMatch };
30 
31  std::array<int, nvar> n[ndet];
32 
33  for (auto &d : n) {
34  for (auto &v : d) {
35  v = 0;
36  }
37  }
38 
39  for (auto &x1 : xmls1) {
40  HcalGenericDetId id(x1.first);
41  auto x2 = xmls2.find(id.rawId());
42  auto subdet = id.genericSubdet();
43  if (subdet == 0 or subdet == 6)
44  continue; //'empty' or 'other'
45 
46  auto &m = n[subdet - 1];
47 
48  m[total]++;
49  if (x2 == xmls2.end()) {
50  m[extra]++;
51  if (testFormat)
52  cout << "Extra detId: " << id << endl;
53  else
54  continue;
55  }
56 
57  const auto &lut1 = x1.second;
58  size_t size = lut1.size();
59 
60  bool zero = true;
61  for (auto &i : lut1) {
62  if (i > 0) {
63  zero = false;
64  break;
65  }
66  }
67  if (zero) {
68  m[zeros]++;
69  if (detail == 1 and testFormat) {
70  cout << "Zero LUT: " << id << endl;
71  }
72  }
73 
74  if (testFormat)
75  continue;
76 
77  const auto &lut2 = x2->second;
78  bool good = size == lut2.size();
79  bool fgGood = size == lut2.size();
80  for (size_t i = 0; i < size and (good or fgGood); ++i) {
81  if (lut1[i] != lut2[i]) {
82  good = false;
83  //Only check fine grain bits in HB and HE
84  if (subdet == 1 || subdet == 2) {
85  if ((lut1[i] & HBandHE_fgBits) != (lut2[i] & HBandHE_fgBits))
86  fgGood = false;
87  }
88  if (detail == 2) {
89  cout << Form("Mismatach in index=%3d, %4d!=%4d, ", int(i), lut1[i], lut2[i]) << id << endl;
90  }
91  }
92  }
93  if (good)
94  m[match]++;
95  if (fgGood)
96  m[fgMatch]++;
97  }
98 
99  if (testFormat) {
100  cout << Form("%3s: %8s %8s %8s", "Det", "total", "zeroes", "extra") << endl;
101  for (auto i : dtype)
102  cout << Form("%3s: %8d %8d %8d", DET[i], n[i][total], n[i][zeros], n[i][extra]) << endl;
103  cout << "--------------------------------------------" << endl;
104  } else {
105  bool good = true;
106  for (auto &d : n) {
107  if (d[total] != d[match]) {
108  good = false;
109  }
110  }
111  cout << Form("%3s: %8s %8s %8s %8s %8s", "Det", "total", "match", "mismatch", "FG match", "FG mismatch")
112  << endl;
113  for (auto i : dtype)
114  cout << Form("%3s: %8d %8d %8d %8d %8d",
115  DET[i],
116  n[i][total],
117  n[i][match],
118  n[i][total] - n[i][match],
119  n[i][fgMatch],
120  n[i][total] - n[i][fgMatch])
121  << endl;
122  cout << "--------------------------------------------" << endl;
123  cout << (good ? "PASS!" : "FAIL!") << endl;
124  }
125 }
size
Write out results.
const_iterator find(uint32_t) const
Definition: LutXml.cc:450
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
d
Definition: ztail.py:151
const_iterator end() const
Definition: LutXml.cc:448
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 127 of file hcalLUT.cc.

References dir2webdir::argc, GCPpyPlots::argv, DMR_cfg::cerr, gather_cfg::cout, HcalLutManager::create_lut_loader(), LutXml::create_lut_map(), dumpLutDiff(), submitPVResolutionJobs::files, contentValuesFiles::fullPath, mergeLUTs(), writedatasetfile::parser, and AlCaHLTBitMon_QueryRunRegistry::string.

127  {
128  optutl::CommandLineParser parser("runTestParameters");
129  parser.parseArguments(argc, argv, true);
130  if (argc < 2) {
131  std::cerr << "runTest: missing input command" << std::endl;
132  } else if (strcmp(argv[1], "merge") == 0) {
133  std::string flist_ = parser.stringValue("storePrepend");
134  std::string out_ = parser.stringValue("outputFile");
135  mergeLUTs(flist_.c_str(), out_.c_str());
136  } else if (strcmp(argv[1], "diff") == 0) {
137  auto files = parser.stringVector("inputFiles");
138  auto detail = parser.integerValue("section");
139 
140  LutXml xmls1(edm::FileInPath(files[0]).fullPath());
141  LutXml xmls2(edm::FileInPath(files[1]).fullPath());
142 
143  xmls1.create_lut_map();
144  xmls2.create_lut_map();
145 
146  cout << files[0] << endl;
147  dumpLutDiff(xmls1, xmls2, true, detail);
148 
149  cout << files[1] << endl;
150  dumpLutDiff(xmls2, xmls1, true, detail);
151 
152  cout << "Comparison" << endl;
153  dumpLutDiff(xmls1, xmls2, false, detail);
154  } else if (strcmp(argv[1], "create-lut-loader") == 0) {
155  std::string _file_list = parser.stringValue("outputFile");
156  std::string _tag = parser.stringValue("tag");
157  std::string _comment = parser.stringValue("storePrepend");
158  const std::string &_prefix = _tag;
159  std::string _version = "1";
160  int _subversion = 0;
161  HcalLutManager manager;
162  manager.create_lut_loader(_file_list, _prefix, _tag, _comment, _tag, _subversion);
163  } else {
164  throw std::invalid_argument(Form("Unknown command: %s", argv[1]));
165  }
166 
167  return 0;
168 }
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)
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

◆ mergeLUTs()

void mergeLUTs ( const char *  flist,
const char *  out 
)

Definition at line 11 of file hcalLUT.cc.

References geometryDiff::file, MillePedeFileConverter_cfg::out, 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