CMS 3D CMS Logo

L1TGlobalPrescalesVetosViewer.cc
Go to the documentation of this file.
1 #include <iomanip>
6 
9 
12 
14 private:
17  int32_t veto_verbosity;
19 
20  std::string hash(void* buf, size_t len) const;
21 
22 public:
23  void analyze(const edm::Event&, const edm::EventSetup&) override;
24 
26  token_ = esConsumes();
27  prescale_table_verbosity = pset.getUntrackedParameter<int32_t>("prescale_table_verbosity", 0);
28  bxmask_map_verbosity = pset.getUntrackedParameter<int32_t>("bxmask_map_verbosity", 0);
29  veto_verbosity = pset.getUntrackedParameter<int32_t>("veto_verbosity", 0);
30  }
31 };
32 
34 #include <cmath>
35 #include <iostream>
36 using namespace std;
37 
40  EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
41  const EVP_MD* md = EVP_get_digestbyname("SHA1");
42  if (!EVP_DigestInit_ex(mdctx, md, nullptr))
43  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash") << "SHA1 initialization error";
44 
45  if (!EVP_DigestUpdate(mdctx, buf, len))
46  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash") << "SHA1 processing error";
47 
48  unsigned char hash[EVP_MAX_MD_SIZE];
49  unsigned int md_len = 0;
50  if (!EVP_DigestFinal_ex(mdctx, hash, &md_len))
51  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash") << "SHA1 finalization error";
52 
53  EVP_MD_CTX_free(mdctx);
54 
55  // re-write bytes in hex
56  char tmp[EVP_MAX_MD_SIZE * 2 + 1];
57  if (md_len > 20)
58  md_len = 20;
59  for (unsigned int i = 0; i < md_len; i++)
60  ::sprintf(&tmp[i * 2], "%02x", hash[i]);
61 
62  tmp[md_len * 2] = 0;
63  return std::string(tmp);
64 }
65 
67  L1TGlobalPrescalesVetos const& ptr = evSetup.getData(token_);
68 
69  edm::LogInfo("") << "L1TGlobalPrescalesVetosViewer:";
70 
71  cout << endl;
72  cout << " version_ = " << ptr.version_ << endl;
73  cout << " bxmask_default_ = " << ptr.bxmask_default_ << endl;
74 
75  size_t len_prescale_table_ = 0;
76  for (size_t col = 0; col < ptr.prescale_table_.size(); col++) {
77  size_t nRows = (ptr.prescale_table_)[col].size();
78  len_prescale_table_ += nRows;
79  if (prescale_table_verbosity > 0) {
80  int column[nRows];
81  for (size_t row = 0; row < nRows; row++)
82  column[row] = (ptr.prescale_table_)[col][row];
83  cout << " prescale_table_[" << col << "][" << nRows << "] = ";
84  if (nRows)
85  cout << hash(column, sizeof(int) * nRows) << endl;
86  else
87  cout << 0 << endl;
88  }
89  }
90  int prescale_table_[len_prescale_table_];
91  for (size_t col = 0, pos = 0; col < ptr.prescale_table_.size(); col++) {
92  size_t nRows = (ptr.prescale_table_)[col].size();
93  for (size_t row = 0; row < nRows; row++, pos++)
94  prescale_table_[pos] = (ptr.prescale_table_)[col][row];
95  }
96  cout << " prescale_table_[[" << len_prescale_table_ << "]] = ";
97  if (len_prescale_table_)
98  cout << hash(prescale_table_, sizeof(int) * len_prescale_table_) << endl;
99  else
100  cout << 0 << endl;
101 
102  if (prescale_table_verbosity > 1) {
103  cout << endl << " Detailed view on the prescales * masks: " << endl;
104  for (size_t col = 0; col < ptr.prescale_table_.size(); col++)
105  cout << setw(8) << " Index " << col;
106  cout << endl;
107  size_t nRows = (ptr.prescale_table_)[0].size();
108  for (size_t row = 0; row < nRows; row++) {
109  for (size_t col = 0; col < ptr.prescale_table_.size(); col++)
110  cout << setw(8) << (ptr.prescale_table_)[col][row];
111  cout << endl;
112  }
113  cout << endl;
114  }
115 
116  size_t len_bxmask_map_ = 0;
117  for (std::map<int, std::vector<int> >::const_iterator it = (ptr.bxmask_map_).begin(); it != (ptr.bxmask_map_).end();
118  it++) {
119  len_bxmask_map_ += it->second.size();
120  if (bxmask_map_verbosity == 1) {
121  int masks[it->second.size()];
122  for (size_t i = 0; i < it->second.size(); i++)
123  masks[i] = it->second[i];
124  cout << " bxmask_map_[" << it->first << "][" << it->second.size() << "] = ";
125  if (!it->second.empty())
126  cout << hash(masks, sizeof(int) * it->second.size()) << endl;
127  else
128  cout << 0 << endl;
129  }
130  if (bxmask_map_verbosity > 1) {
131  cout << " bxmask_map_[" << it->first << "][" << it->second.size() << "] = ";
132  for (size_t algo = 0; algo < it->second.size(); algo++)
133  cout << it->second[algo] << ", ";
134  cout << endl;
135  }
136  }
137  int bxmask_map_[len_bxmask_map_];
138  size_t pos = 0;
139  for (std::map<int, std::vector<int> >::const_iterator it = (ptr.bxmask_map_).begin(); it != (ptr.bxmask_map_).end();
140  it++) {
141  for (size_t i = 0; i < it->second.size(); i++, pos++)
142  bxmask_map_[pos] = it->second[i];
143  }
144  cout << " bxmask_map_[[" << len_bxmask_map_ << "]] = ";
145  if (len_bxmask_map_)
146  cout << hash(bxmask_map_, sizeof(int) * len_bxmask_map_) << endl;
147  else
148  cout << 0 << endl;
149 
150  int veto_[(ptr.veto_).size()];
151  bool veto_allZeros = true;
152  for (size_t i = 0; i < (ptr.veto_).size(); i++) {
153  veto_[i] = (ptr.veto_)[i];
154  if (veto_[i])
155  veto_allZeros = false;
156  }
157  cout << " veto_[" << (ptr.veto_).size() << "] = ";
158  if (veto_verbosity == 0) {
159  if (!(ptr.veto_).empty()) {
160  cout << hash(veto_, sizeof(int) * (ptr.veto_).size());
161  if (veto_allZeros)
162  cout << " (all zeros)" << endl;
163  else
164  cout << endl;
165  } else
166  cout << 0 << endl;
167  } else
168  for (size_t i = 0; i < (ptr.veto_).size(); i++)
169  cout << veto_[i] << endl;
170 
171  int exp_ints_[(ptr.exp_ints_).size()];
172  for (size_t i = 0; i < (ptr.exp_ints_).size(); i++)
173  exp_ints_[i] = (ptr.exp_ints_)[i];
174  cout << " exp_ints_[" << (ptr.exp_ints_).size() << "] = ";
175  if (!(ptr.exp_ints_).empty())
176  cout << hash(exp_ints_, sizeof(int) * (ptr.exp_ints_).size()) << endl;
177  else
178  cout << 0 << endl;
179 
180  int exp_doubles_[(ptr.exp_doubles_).size()];
181  for (size_t i = 0; i < (ptr.exp_doubles_).size(); i++)
182  exp_ints_[i] = (ptr.exp_doubles_)[i];
183  cout << " exp_doubles_[" << (ptr.exp_doubles_).size() << "] = ";
184  if (!(ptr.exp_doubles_).empty())
185  cout << hash(exp_doubles_, sizeof(int) * (ptr.exp_doubles_).size()) << endl;
186  else
187  cout << 0 << endl;
188 }
189 
193 
size
Write out results.
void openssl_init()
Definition: openssl_init.cc:5
edm::ESGetToken< L1TGlobalPrescalesVetos, L1TGlobalPrescalesVetosRcd > token_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
L1TGlobalPrescalesVetosViewer(const edm::ParameterSet &pset)
std::string hash(void *buf, size_t len) const
std::map< int, std::vector< int > > bxmask_map_
#define EVP_MD_CTX_free
Definition: openssl_init.h:7
std::vector< double > exp_doubles_
void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
#define EVP_MD_CTX_new
Definition: openssl_init.h:6
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Info, false > LogInfo
std::vector< std::vector< int > > prescale_table_
col
Definition: cuy.py:1009
tmp
align.sh
Definition: createJobs.py:716