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;
27 
28 public:
29  void analyze(const edm::Event &, const edm::EventSetup &) override;
30 
31  explicit L1TMuonBarrelParamsViewer(const edm::ParameterSet &) : token_{esConsumes()} { printPtaThreshold = false; }
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 
68  L1TMuonBarrelParams const &ptr = evSetup.getData(token_);
69 
71 
72  cout << "AssLUTPath: " << ptr1->AssLUTPath() << endl;
73 
74  // typedef std::map<short, short, std::less<short> > LUT;
75 
76  size_t k = 0; // avoid using l
77  for (const auto &lut : ptr1->pta_lut()) {
78  if (!lut.empty()) {
79  cout << " pta_lut[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
80  int lut_[lut.size()], i = 0;
81  for (const pair<const short, short> &p : lut)
82  lut_[i++] = p.first * 0xFFFF + p.second;
83  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
84  } else {
85  cout << " pta_lut[" << setw(2) << k << "]= [0] " << endl;
86  }
87  k++;
88  }
89 
90  cout << " pta_threshold= [" << ptr1->pta_threshold().size() << "] " << flush;
91  int pta_threshold[ptr1->pta_threshold().size()];
92  for (unsigned int i = 0; i < ptr1->pta_threshold().size(); i++) {
93  pta_threshold[i] = ptr1->pta_threshold()[i];
94  if (printPtaThreshold)
95  cout << " " << pta_threshold[i] << endl;
96  }
97  if (!ptr1->pta_threshold().empty())
98  cout << hash(pta_threshold, sizeof(int) * ptr1->pta_threshold().size()) << endl;
99  else
100  cout << endl;
101 
102  k = 0;
103  for (const auto &lut : ptr1->pta_lut()) {
104  if (!lut.empty()) {
105  cout << " phi_lut[" << k << "]= [" << lut.size() << "] " << flush;
106  int lut_[lut.size()], i = 0;
107  for (const pair<const short, short> &p : lut)
108  lut_[i++] = p.first * 0xFFFF + p.second;
109  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
110  } else {
111  cout << " phi_lut[" << k << "]= [0] " << endl;
112  }
113  k++;
114  }
115 
116  k = 0;
117  for (const auto &lu : ptr1->ext_lut()) {
118  const auto &lut = lu.low;
119  if (!lut.empty()) {
120  cout << " ext_lut_low[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
121  int lut_[lut.size()], i = 0;
122  for (const pair<const short, short> &p : lut)
123  lut_[i++] = p.first * 0xFFFF + p.second;
124  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
125  } else {
126  cout << " ext_lut_low[" << setw(2) << k << "]= [0] " << endl;
127  }
128  k++;
129  }
130 
131  k = 0;
132  for (const auto &lu : ptr1->ext_lut()) {
133  const auto &lut = lu.high;
134  if (!lut.empty()) {
135  cout << " ext_lut_high[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
136  int lut_[lut.size()], i = 0;
137  for (const pair<const short, short> &p : lut)
138  lut_[i++] = p.first * 0xFFFF + p.second;
139  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
140  } else {
141  cout << " ext_lut_high[" << setw(2) << k << "]= [0] " << endl;
142  }
143  k++;
144  }
145 
146  // typedef std::map< LUTID, LUTCONT > qpLUT;
147  for (const auto &item : ptr1->qp_lut()) {
148  cout << " qp_lut[" << item.first.first << "," << item.first.second << "]= " << item.second.first << ", ["
149  << item.second.second.size() << "] " << flush;
150  if (!item.second.second.empty()) {
151  int lut_[item.second.second.size()];
152  for (size_t i = 0; i < item.second.second.size(); i++)
153  lut_[i] = item.second.second[i];
154  cout << hash(lut_, sizeof(int) * item.second.second.size()) << endl;
155  } else {
156  cout << endl;
157  }
158  }
159 
160  // typedef std::map<short, L1MuDTEtaPattern, std::less<short> > etaLUT;
161  for (const pair<const short, L1MuDTEtaPattern> &item : ptr1->eta_lut())
162  cout << " eta_lut[" << item.first << "]= " << endl << item.second << endl;
163 
164  cout << "PT_Assignment_nbits_Phi= " << ptr1->get_PT_Assignment_nbits_Phi() << endl;
165  cout << "PT_Assignment_nbits_PhiB= " << ptr1->get_PT_Assignment_nbits_PhiB() << endl;
166  cout << "PHI_Assignment_nbits_Phi= " << ptr1->get_PHI_Assignment_nbits_Phi() << endl;
167  cout << "PHI_Assignment_nbits_PhiB= " << ptr1->get_PHI_Assignment_nbits_PhiB() << endl;
168  cout << "Extrapolation_nbits_Phi= " << ptr1->get_Extrapolation_nbits_Phi() << endl;
169  cout << "Extrapolation_nbits_PhiB= " << ptr1->get_Extrapolation_nbits_PhiB() << endl;
170  cout << "BX_min= " << ptr1->get_BX_min() << endl;
171  cout << "BX_max= " << ptr1->get_BX_max() << endl;
172  cout << "Extrapolation_Filter= " << ptr1->get_Extrapolation_Filter() << endl;
173  cout << "OutOfTime_Filter_Window= " << ptr1->get_OutOfTime_Filter_Window() << endl;
174 
175  cout << boolalpha;
176  cout << "OutOfTime_Filter= " << ptr1->get_OutOfTime_Filter() << endl;
177  cout << "Open_LUTs= " << ptr1->get_Open_LUTs() << endl;
178  cout << "EtaTrackFinder= " << ptr1->get_EtaTrackFinder() << endl;
179  cout << "Extrapolation_21= " << ptr1->get_Extrapolation_21() << endl;
180  cout << "DisableNewAlgo= " << ptr1->get_DisableNewAlgo() << endl;
181  cout << noboolalpha;
182 
183  // FW version
184  cout << "fwVersion= " << ptr1->fwVersion() << endl;
185  cout << "version= " << ptr1->version_ << endl;
186 }
187 
191 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void openssl_init()
Definition: openssl_init.cc:5
edm::ESGetToken< L1TMuonBarrelParams, L1TMuonBarrelParamsRcd > token_
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
#define EVP_MD_CTX_new
Definition: openssl_init.h:6
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool getData(T &iHolder) const
Definition: EventSetup.h:122
std::vector< int > pta_threshold() const
std::vector< LUT > pta_lut() const
L1TMuonBarrelParamsViewer(const edm::ParameterSet &)
void analyze(const edm::Event &, const edm::EventSetup &) override
tmp
align.sh
Definition: createJobs.py:716
std::vector< LUTParams::extLUT > ext_lut() const