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;
18 
19  std::string hash(void* buf, size_t len) const;
20 
21 public:
22  void analyze(const edm::Event&, const edm::EventSetup&) override;
23 
25  prescale_table_verbosity = pset.getUntrackedParameter<int32_t>("prescale_table_verbosity", 0);
26  bxmask_map_verbosity = pset.getUntrackedParameter<int32_t>("bxmask_map_verbosity", 0);
27  veto_verbosity = pset.getUntrackedParameter<int32_t>("veto_verbosity", 0);
28  }
29 
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 
68  evSetup.get<L1TGlobalPrescalesVetosRcd>().get(handle1);
69  std::shared_ptr<L1TGlobalPrescalesVetos> ptr(new L1TGlobalPrescalesVetos(*(handle1.product())));
70 
71  edm::LogInfo("") << "L1TGlobalPrescalesVetosViewer:";
72 
73  cout << endl;
74  cout << " version_ = " << ptr->version_ << endl;
75  cout << " bxmask_default_ = " << ptr->bxmask_default_ << endl;
76 
77  size_t len_prescale_table_ = 0;
78  for (size_t col = 0; col < ptr->prescale_table_.size(); col++) {
79  size_t nRows = (ptr->prescale_table_)[col].size();
80  len_prescale_table_ += nRows;
81  if (prescale_table_verbosity > 0) {
82  int column[nRows];
83  for (size_t row = 0; row < nRows; row++)
84  column[row] = (ptr->prescale_table_)[col][row];
85  cout << " prescale_table_[" << col << "][" << nRows << "] = ";
86  if (nRows)
87  cout << hash(column, sizeof(int) * nRows) << endl;
88  else
89  cout << 0 << endl;
90  }
91  }
92  int prescale_table_[len_prescale_table_];
93  for (size_t col = 0, pos = 0; col < ptr->prescale_table_.size(); col++) {
94  size_t nRows = (ptr->prescale_table_)[col].size();
95  for (size_t row = 0; row < nRows; row++, pos++)
96  prescale_table_[pos] = (ptr->prescale_table_)[col][row];
97  }
98  cout << " prescale_table_[[" << len_prescale_table_ << "]] = ";
99  if (len_prescale_table_)
100  cout << hash(prescale_table_, sizeof(int) * len_prescale_table_) << endl;
101  else
102  cout << 0 << endl;
103 
104  if (prescale_table_verbosity > 1) {
105  cout << endl << " Detailed view on the prescales * masks: " << endl;
106  for (size_t col = 0; col < ptr->prescale_table_.size(); col++)
107  cout << setw(8) << " Index " << col;
108  cout << endl;
109  size_t nRows = (ptr->prescale_table_)[0].size();
110  for (size_t row = 0; row < nRows; row++) {
111  for (size_t col = 0; col < ptr->prescale_table_.size(); col++)
112  cout << setw(8) << (ptr->prescale_table_)[col][row];
113  cout << endl;
114  }
115  cout << endl;
116  }
117 
118  size_t len_bxmask_map_ = 0;
119  for (std::map<int, std::vector<int> >::const_iterator it = (ptr->bxmask_map_).begin(); it != (ptr->bxmask_map_).end();
120  it++) {
121  len_bxmask_map_ += it->second.size();
122  if (bxmask_map_verbosity == 1) {
123  int masks[it->second.size()];
124  for (size_t i = 0; i < it->second.size(); i++)
125  masks[i] = it->second[i];
126  cout << " bxmask_map_[" << it->first << "][" << it->second.size() << "] = ";
127  if (!it->second.empty())
128  cout << hash(masks, sizeof(int) * it->second.size()) << endl;
129  else
130  cout << 0 << endl;
131  }
132  if (bxmask_map_verbosity > 1) {
133  cout << " bxmask_map_[" << it->first << "][" << it->second.size() << "] = ";
134  for (size_t algo = 0; algo < it->second.size(); algo++)
135  cout << it->second[algo] << ", ";
136  cout << endl;
137  }
138  }
139  int bxmask_map_[len_bxmask_map_];
140  size_t pos = 0;
141  for (std::map<int, std::vector<int> >::const_iterator it = (ptr->bxmask_map_).begin(); it != (ptr->bxmask_map_).end();
142  it++) {
143  for (size_t i = 0; i < it->second.size(); i++, pos++)
144  bxmask_map_[pos] = it->second[i];
145  }
146  cout << " bxmask_map_[[" << len_bxmask_map_ << "]] = ";
147  if (len_bxmask_map_)
148  cout << hash(bxmask_map_, sizeof(int) * len_bxmask_map_) << endl;
149  else
150  cout << 0 << endl;
151 
152  int veto_[(ptr->veto_).size()];
153  bool veto_allZeros = true;
154  for (size_t i = 0; i < (ptr->veto_).size(); i++) {
155  veto_[i] = (ptr->veto_)[i];
156  if (veto_[i])
157  veto_allZeros = false;
158  }
159  cout << " veto_[" << (ptr->veto_).size() << "] = ";
160  if (veto_verbosity == 0) {
161  if (!(ptr->veto_).empty()) {
162  cout << hash(veto_, sizeof(int) * (ptr->veto_).size());
163  if (veto_allZeros)
164  cout << " (all zeros)" << endl;
165  else
166  cout << endl;
167  } else
168  cout << 0 << endl;
169  } else
170  for (size_t i = 0; i < (ptr->veto_).size(); i++)
171  cout << veto_[i] << endl;
172 
173  int exp_ints_[(ptr->exp_ints_).size()];
174  for (size_t i = 0; i < (ptr->exp_ints_).size(); i++)
175  exp_ints_[i] = (ptr->exp_ints_)[i];
176  cout << " exp_ints_[" << (ptr->exp_ints_).size() << "] = ";
177  if (!(ptr->exp_ints_).empty())
178  cout << hash(exp_ints_, sizeof(int) * (ptr->exp_ints_).size()) << endl;
179  else
180  cout << 0 << endl;
181 
182  int exp_doubles_[(ptr->exp_doubles_).size()];
183  for (size_t i = 0; i < (ptr->exp_doubles_).size(); i++)
184  exp_ints_[i] = (ptr->exp_doubles_)[i];
185  cout << " exp_doubles_[" << (ptr->exp_doubles_).size() << "] = ";
186  if (!(ptr->exp_doubles_).empty())
187  cout << hash(exp_doubles_, sizeof(int) * (ptr->exp_doubles_).size()) << endl;
188  else
189  cout << 0 << endl;
190 }
191 
195 
size
Write out results.
void openssl_init()
Definition: openssl_init.cc:5
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1TGlobalPrescalesVetosViewer(const edm::ParameterSet &pset)
std::string hash(void *buf, size_t len) const
#define EVP_MD_CTX_free
Definition: openssl_init.h:7
void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
#define EVP_MD_CTX_new
Definition: openssl_init.h:6
T get() const
Definition: EventSetup.h:82
Log< level::Info, false > LogInfo
HLT enums.
col
Definition: cuy.py:1009
tmp
align.sh
Definition: createJobs.py:716