CMS 3D CMS Logo

hcalLUT.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <stdexcept>
3 #include <sstream>
4 #include "TString.h"
7 
8 using namespace std;
9 
10 void mergeLUTs(const char *flist, const char *out) {
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 }
20 
21 void dumpLutDiff(LutXml &xmls1, LutXml &xmls2, bool testFormat = true, int detail = 0) {
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 }
108 
109 int main(int argc, char **argv) {
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 }
cmsBatch.argv
argv
Definition: cmsBatch.py:279
CommandLineParser.h
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
main
int main(int argc, char **argv)
Definition: hcalLUT.cc:109
HcalGenericDetId
Definition: HcalGenericDetId.h:15
dir2webdir.argc
argc
Definition: dir2webdir.py:39
LutXml::create_lut_map
int create_lut_map(void)
Definition: LutXml.cc:336
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
SiPixelPI::zero
Definition: SiPixelPayloadInspectorHelper.h:39
detail
Definition: ConvertingESProducerWithDependenciesT.h:23
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
submitPVResolutionJobs.files
files
Definition: submitPVResolutionJobs.py:373
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
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
std
Definition: JetResolutionObject.h:76
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
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
HcalLutManager.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
optutl::CommandLineParser
Definition: CommandLineParser.h:10