CMS 3D CMS Logo

L1TMuonBarrelParamsViewer.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <iostream>
3 
5 
8 
11 
18 
19 #include <iostream>
20 using namespace std;
21 
23 private:
24  std::string hash(void *buf, size_t len) const;
26 
27 public:
28  void analyze(const edm::Event &, const edm::EventSetup &) override;
29 
30  explicit L1TMuonBarrelParamsViewer(const edm::ParameterSet &) : edm::EDAnalyzer() { printPtaThreshold = false; }
31  ~L1TMuonBarrelParamsViewer(void) override {}
32 };
33 
35 #include <cmath>
36 #include <iostream>
37 using namespace std;
38 
41  EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
42  const EVP_MD *md = EVP_get_digestbyname("SHA1");
43  if (!EVP_DigestInit_ex(mdctx, md, nullptr))
44  throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 initialization error";
45 
46  if (!EVP_DigestUpdate(mdctx, buf, len))
47  throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 processing error";
48 
49  unsigned char hash[EVP_MAX_MD_SIZE];
50  unsigned int md_len = 0;
51  if (!EVP_DigestFinal_ex(mdctx, hash, &md_len))
52  throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 finalization error";
53 
54  EVP_MD_CTX_free(mdctx);
55 
56  // re-write bytes in hex
57  char tmp[EVP_MAX_MD_SIZE * 2 + 1];
58  if (md_len > 20)
59  md_len = 20;
60  for (unsigned int i = 0; i < md_len; i++)
61  ::sprintf(&tmp[i * 2], "%02x", hash[i]);
62 
63  tmp[md_len * 2] = 0;
64  return std::string(tmp);
65 }
66 
69  evSetup.get<L1TMuonBarrelParamsRcd>().get(handle1);
70  std::shared_ptr<L1TMuonBarrelParams> ptr(new L1TMuonBarrelParams(*(handle1.product())));
71 
73 
74  cout << "AssLUTPath: " << ptr1->AssLUTPath() << endl;
75 
76  // typedef std::map<short, short, std::less<short> > LUT;
77 
78  size_t k = 0; // avoid using l
79  for (const auto &lut : ptr1->pta_lut()) {
80  if (!lut.empty()) {
81  cout << " pta_lut[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
82  int lut_[lut.size()], i = 0;
83  for (const pair<const short, short> &p : lut)
84  lut_[i++] = p.first * 0xFFFF + p.second;
85  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
86  } else {
87  cout << " pta_lut[" << setw(2) << k << "]= [0] " << endl;
88  }
89  k++;
90  }
91 
92  cout << " pta_threshold= [" << ptr1->pta_threshold().size() << "] " << flush;
93  int pta_threshold[ptr1->pta_threshold().size()];
94  for (unsigned int i = 0; i < ptr1->pta_threshold().size(); i++) {
95  pta_threshold[i] = ptr1->pta_threshold()[i];
96  if (printPtaThreshold)
97  cout << " " << pta_threshold[i] << endl;
98  }
99  if (!ptr1->pta_threshold().empty())
100  cout << hash(pta_threshold, sizeof(int) * ptr1->pta_threshold().size()) << endl;
101  else
102  cout << endl;
103 
104  k = 0;
105  for (const auto &lut : ptr1->pta_lut()) {
106  if (!lut.empty()) {
107  cout << " phi_lut[" << k << "]= [" << lut.size() << "] " << flush;
108  int lut_[lut.size()], i = 0;
109  for (const pair<const short, short> &p : lut)
110  lut_[i++] = p.first * 0xFFFF + p.second;
111  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
112  } else {
113  cout << " phi_lut[" << k << "]= [0] " << endl;
114  }
115  k++;
116  }
117 
118  k = 0;
119  for (const auto &lu : ptr1->ext_lut()) {
120  const auto &lut = lu.low;
121  if (!lut.empty()) {
122  cout << " ext_lut_low[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
123  int lut_[lut.size()], i = 0;
124  for (const pair<const short, short> &p : lut)
125  lut_[i++] = p.first * 0xFFFF + p.second;
126  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
127  } else {
128  cout << " ext_lut_low[" << setw(2) << k << "]= [0] " << endl;
129  }
130  k++;
131  }
132 
133  k = 0;
134  for (const auto &lu : ptr1->ext_lut()) {
135  const auto &lut = lu.high;
136  if (!lut.empty()) {
137  cout << " ext_lut_high[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
138  int lut_[lut.size()], i = 0;
139  for (const pair<const short, short> &p : lut)
140  lut_[i++] = p.first * 0xFFFF + p.second;
141  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
142  } else {
143  cout << " ext_lut_high[" << setw(2) << k << "]= [0] " << endl;
144  }
145  k++;
146  }
147 
148  // typedef std::map< LUTID, LUTCONT > qpLUT;
149  for (const auto &item : ptr1->qp_lut()) {
150  cout << " qp_lut[" << item.first.first << "," << item.first.second << "]= " << item.second.first << ", ["
151  << item.second.second.size() << "] " << flush;
152  if (!item.second.second.empty()) {
153  int lut_[item.second.second.size()];
154  for (size_t i = 0; i < item.second.second.size(); i++)
155  lut_[i] = item.second.second[i];
156  cout << hash(lut_, sizeof(int) * item.second.second.size()) << endl;
157  } else {
158  cout << endl;
159  }
160  }
161 
162  // typedef std::map<short, L1MuDTEtaPattern, std::less<short> > etaLUT;
163  for (const pair<const short, L1MuDTEtaPattern> &item : ptr1->eta_lut())
164  cout << " eta_lut[" << item.first << "]= " << endl << item.second << endl;
165 
166  cout << "PT_Assignment_nbits_Phi= " << ptr1->get_PT_Assignment_nbits_Phi() << endl;
167  cout << "PT_Assignment_nbits_PhiB= " << ptr1->get_PT_Assignment_nbits_PhiB() << endl;
168  cout << "PHI_Assignment_nbits_Phi= " << ptr1->get_PHI_Assignment_nbits_Phi() << endl;
169  cout << "PHI_Assignment_nbits_PhiB= " << ptr1->get_PHI_Assignment_nbits_PhiB() << endl;
170  cout << "Extrapolation_nbits_Phi= " << ptr1->get_Extrapolation_nbits_Phi() << endl;
171  cout << "Extrapolation_nbits_PhiB= " << ptr1->get_Extrapolation_nbits_PhiB() << endl;
172  cout << "BX_min= " << ptr1->get_BX_min() << endl;
173  cout << "BX_max= " << ptr1->get_BX_max() << endl;
174  cout << "Extrapolation_Filter= " << ptr1->get_Extrapolation_Filter() << endl;
175  cout << "OutOfTime_Filter_Window= " << ptr1->get_OutOfTime_Filter_Window() << endl;
176 
177  cout << boolalpha;
178  cout << "OutOfTime_Filter= " << ptr1->get_OutOfTime_Filter() << endl;
179  cout << "Open_LUTs= " << ptr1->get_Open_LUTs() << endl;
180  cout << "EtaTrackFinder= " << ptr1->get_EtaTrackFinder() << endl;
181  cout << "Extrapolation_21= " << ptr1->get_Extrapolation_21() << endl;
182  cout << "DisableNewAlgo= " << ptr1->get_DisableNewAlgo() << endl;
183  cout << noboolalpha;
184 
185  // FW version
186  cout << "fwVersion= " << ptr1->fwVersion() << endl;
187  cout << "version= " << ptr1->version_ << endl;
188 }
189 
193 
void openssl_init()
Definition: openssl_init.cc:5
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
#define EVP_MD_CTX_free
Definition: openssl_init.h:7
std::string hash(void *buf, size_t len) const
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
HLT enums.
L1TMuonBarrelParamsViewer(const edm::ParameterSet &)
void analyze(const edm::Event &, const edm::EventSetup &) override
tmp
align.sh
Definition: createJobs.py:716