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"

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 21 of file hcalLUT.cc.

21  {
22  const int ndet = 5;
23  const char *DET[ndet] = {"HB", "HE", "HO", "HF", "HT"};
24  const int dtype[ndet] = {0, 1, 2, 3, 4};
25 
26  const int nvar = 4;
27  enum vtype { total, extra, zeros, match };
28 
29  std::array<int, nvar> n[ndet];
30 
31  for (auto &d : n) {
32  for (auto &v : d) {
33  v = 0;
34  }
35  }
36 
37  for (auto &x1 : xmls1) {
38  HcalGenericDetId id(x1.first);
39  auto x2 = xmls2.find(id.rawId());
40  auto subdet = id.genericSubdet();
41  if (subdet == 0 or subdet == 6)
42  continue; //'empty' or 'other'
43 
44  auto &m = n[subdet - 1];
45 
46  m[total]++;
47  if (x2 == xmls2.end()) {
48  m[extra]++;
49  if (testFormat)
50  cout << "Extra detId: " << id << endl;
51  else
52  continue;
53  }
54 
55  const auto &lut1 = x1.second;
56  size_t size = lut1.size();
57 
58  bool zero = true;
59  for (auto &i : lut1) {
60  if (i > 0) {
61  zero = false;
62  break;
63  }
64  }
65  if (zero) {
66  m[zeros]++;
67  if (detail == 1 and testFormat) {
68  cout << "Zero LUT: " << id << endl;
69  }
70  }
71 
72  if (testFormat)
73  continue;
74 
75  const auto &lut2 = x2->second;
76  bool good = size == lut2.size();
77  for (size_t i = 0; i < size and good; ++i) {
78  if (lut1[i] != lut2[i]) {
79  good = false;
80  if (detail == 2) {
81  cout << Form("Mismatach in index=%3d, %4d!=%4d, ", int(i), lut1[i], lut2[i]) << id << endl;
82  }
83  }
84  }
85  if (good)
86  m[match]++;
87  }
88 
89  if (testFormat) {
90  cout << Form("%3s: %8s %8s %8s", "Det", "total", "zeroes", "extra") << endl;
91  for (auto i : dtype)
92  cout << Form("%3s: %8d %8d %8d", DET[i], n[i][total], n[i][zeros], n[i][extra]) << endl;
93  cout << "--------------------------------------------" << endl;
94  } else {
95  bool good = true;
96  for (auto &d : n) {
97  if (d[total] != d[match]) {
98  good = false;
99  }
100  }
101  cout << Form("%3s: %8s %8s %8s", "Det", "total", "match", "mismatch") << endl;
102  for (auto i : dtype)
103  cout << Form("%3s: %8d %8d %8d", DET[i], n[i][total], n[i][match], n[i][total] - n[i][match]) << endl;
104  cout << "--------------------------------------------" << endl;
105  cout << (good ? "PASS!" : "FAIL!") << endl;
106  }
107 }

References gather_cfg::cout, ztail::d, runTauDisplay::dtype, LutXml::end(), LutXml::find(), mps_fire::i, triggerObjects_cff::id, visualization-live-secondInstance_cfg::m, match(), dqmiodumpmetadata::n, or, std::size(), dqmMemoryStats::total, findQualityFiles::v, testProducerWithPsetDescEmpty_cfi::x1, and testProducerWithPsetDescEmpty_cfi::x2.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 109 of file hcalLUT.cc.

109  {
110  optutl::CommandLineParser parser("runTestParameters");
111  parser.parseArguments(argc, argv, true);
112  if (argc < 2) {
113  std::cerr << "runTest: missing input command" << std::endl;
114  } else if (strcmp(argv[1], "merge") == 0) {
115  std::string flist_ = parser.stringValue("storePrepend");
116  std::string out_ = parser.stringValue("outputFile");
117  mergeLUTs(flist_.c_str(), out_.c_str());
118  } else if (strcmp(argv[1], "diff") == 0) {
119  auto files = parser.stringVector("inputFiles");
120  auto detail = parser.integerValue("section");
121 
122  LutXml xmls1(edm::FileInPath(files[0]).fullPath());
123  LutXml xmls2(edm::FileInPath(files[1]).fullPath());
124 
125  xmls1.create_lut_map();
126  xmls2.create_lut_map();
127 
128  cout << files[0] << endl;
129  dumpLutDiff(xmls1, xmls2, true, detail);
130 
131  cout << files[1] << endl;
132  dumpLutDiff(xmls2, xmls1, true, detail);
133 
134  cout << "Comparison" << endl;
135  dumpLutDiff(xmls1, xmls2, false, detail);
136  } else if (strcmp(argv[1], "create-lut-loader") == 0) {
137  std::string _file_list = parser.stringValue("outputFile");
138  std::string _tag = parser.stringValue("tag");
139  std::string _comment = parser.stringValue("storePrepend");
140  const std::string &_prefix = _tag;
141  std::string _version = "1";
142  int _subversion = 0;
143  HcalLutManager manager;
144  manager.create_lut_loader(_file_list, _prefix, _tag, _comment, _tag, _subversion);
145  } else {
146  throw std::invalid_argument(Form("Unknown command: %s", argv[1]));
147  }
148 
149  return 0;
150 }

References dir2webdir::argc, cmsBatch::argv, beam_dqm_sourceclient-live_cfg::cerr, gather_cfg::cout, HcalLutManager::create_lut_loader(), LutXml::create_lut_map(), dumpLutDiff(), MainPageGenerator::files, contentValuesFiles::fullPath, mergeLUTs(), writedatasetfile::parser, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ mergeLUTs()

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

Definition at line 10 of file hcalLUT.cc.

10  {
11  LutXml xmls;
12  stringstream ss(flist);
13  while (ss.good()) {
14  string file;
15  ss >> file;
16  xmls += LutXml(file);
17  }
18  xmls.write(out);
19 }

References FrontierConditions_GlobalTag_cff::file, MillePedeFileConverter_cfg::out, contentValuesCheck::ss, and XMLDOMBlock::write().

Referenced by main().

cmsBatch.argv
argv
Definition: cmsBatch.py:279
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HcalGenericDetId
Definition: HcalGenericDetId.h:15
dir2webdir.argc
argc
Definition: dir2webdir.py:39
XMLDOMBlock::write
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
gather_cfg.cout
cout
Definition: gather_cfg.py:144
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
LutXml::end
const_iterator end() const
Definition: LutXml.cc:446
findQualityFiles.v
v
Definition: findQualityFiles.py:179
HcalLutManager::create_lut_loader
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)
Definition: HcalLutManager.cc:1540
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::FileInPath
Definition: FileInPath.h:64
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
MainPageGenerator.files
files
Definition: MainPageGenerator.py:256
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mergeLUTs
void mergeLUTs(const char *flist, const char *out)
Definition: hcalLUT.cc:10
LutXml::find
const_iterator find(uint32_t) const
Definition: LutXml.cc:448
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dumpLutDiff
void dumpLutDiff(LutXml &xmls1, LutXml &xmls2, bool testFormat=true, int detail=0)
Definition: hcalLUT.cc:21
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
runTauDisplay.dtype
dtype
Definition: runTauDisplay.py:121
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
HcalLutManager
Various manipulations with trigger Lookup Tables.
Definition: HcalLutManager.h:39
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
or
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
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ztail.d
d
Definition: ztail.py:151
LutXml
Definition: LutXml.h:27
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
optutl::CommandLineParser
Definition: CommandLineParser.h:10